1.properties文件位置的关系:当properties文件放在src目录下时,编译会自动把src里的文件放到bin文件平级,因此可用this.getClass.getClassLoader.getResourceAsStream(fileName)读取,当把properties文件放到包里时,则应加相应的包路径,如:

props.load(Test.class.getClassLoader().getResourceAsStream("abc.properties"));

package wang.hhtp;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties; public class PropertiesUtils
{
private static PropertiesUtils propertiesUtils=null;
private static Map<String,String> proMap=new HashMap<String,String>(); private PropertiesUtils()
{
InputStream inputStream=null;
try {
Properties pro=new Properties();
inputStream =getClass().getClassLoader().getResourceAsStream("abc.properties");
pro.load(inputStream);
Iterator ite=pro.keySet().iterator(); while(ite.hasNext()){
String key=(String) ite.next();
String value=pro.getProperty(key);
proMap.put(key, value);
}
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} public static PropertiesUtils getInstance(){
if(propertiesUtils ==null){
propertiesUtils=new PropertiesUtils();
}
return propertiesUtils;
} public String getValue(String key){
PropertiesUtils pro= PropertiesUtils.getInstance();
if(StringUtils.isNotBlank(key)){
String value=pro.proMap.get(key);
return value;
}
return key;
}
}

2.也可以用 static  类静态加载

class Properties{

    private static Properties props = new Properties();

    static {
try {
props.load(Test.class.getClassLoader().getResourceAsStream("com/abc.properties"));
} catch (Exception e) {
e.printStackTrace();
}
} public static String getProperty(String key){
return props.getProperty(key);
}
}

3.js  删除 数组某个元素

参考:http://my.oschina.net/u/2331760/blog/511439

今天 学习用到的一些知识(properties 读取,js 删除元素)的更多相关文章

  1. jsp学习--基本语法和基础知识

    一.JSP简单介绍 1.什么是JSP? JSP全称是Java Server Pages,它和servle技术一样,都是SUN公司定义的一种用于开发动态web资源的技术. JSP这门技术的最大的特点在于 ...

  2. JSP的学习(3)——语法知识二之page指令

    本篇接上一篇<JSP的学习(2)——语法知识一>,继续来学习JSP的语法.本文主要从JSP指令中的page指令,对其各个属性进行详细的学习: JSP指令: JSP指令是为JSP引擎而设计的 ...

  3. JSP的学习(2)——语法知识一

    上一篇<JSP的学习>讲述了JSP的一些基础知识和底层原理,本篇将来学习JSP所需掌握的语法知识等. JSP的语法主要包括以下几个部分的内容: 1)         JSP模板元素 2)  ...

  4. IP地址和子网划分学习笔记之《预备知识:进制计数》

    一.序:IP地址和子网划分学习笔记开篇 只要记住你的名字,不管你在世界的哪个地方,我一定会去见你.——新海诚 电影<你的名字> 在我们的日常生活中,每个人的名字对应一个唯一的身(敏)份(感 ...

  5. tensorflow学习笔记(3)前置数学知识

    tensorflow学习笔记(3)前置数学知识 首先是神经元的模型 接下来是激励函数 神经网络的复杂度计算 层数:隐藏层+输出层 总参数=总的w+b 下图为2层 如下图 w为3*4+4个   b为4* ...

  6. ios开发学习笔记001-C语言基础知识

    先来学习一下C语言基础知识,总结如下: 在xcode下编写代码. 1.编写代码 2.编译:cc –c 文件名.c 编译成功会生成一个 .o的目标文件 3.链接:把目标文件.o和系统自带的库合并在一起, ...

  7. WPF学习08:MVVM 预备知识之COMMAND

    WPF内建的COMMAND是GOF 提出的23种设计模式中,命令模式的实现. 本文是WPF学习07:MVVM 预备知识之数据绑定的后续,将说明实现COMMAND的三个重点:ICommand  Comm ...

  8. Java学习需要掌握的一些知识

    Java学习需要掌握的一些知识: <一>1.Jvm 部分Jvm 内存模型.Jvm 内存结构.Jvm 参数调优.Java 垃圾回收<二>Java 基础部分1.必须会使用 List ...

  9. 【Java Web开发学习】Spring加载外部properties配置文件

    [Java Web开发学习]Spring加载外部properties配置文件 转载:https://www.cnblogs.com/yangchongxing/p/9136505.html 1.声明属 ...

随机推荐

  1. Object-Detection中常用的概念解析

    常用的Region Proposal Selective Search Edge Boxes Softmax-loss softmax-loss层和softmax层计算大致是相同的,softmax是一 ...

  2. generateScriptFile.py脚本使用过程中遇到的问题及解决

    generateScriptFile.py脚本 #!/usr/bin/env python # -*- coding: utf-8 -*- """ use case: p ...

  3. mybatis拓展框架对比

    对比项 mybatis-plus mybatis-enhance mapper fastmybatis 表名映射 @TableName @Table JPA:@Table JPA:@Table 主键映 ...

  4. C的指针疑惑:C和指针13(高级指针话题)上

    int *f(); f为一个函数,返回值类型是一个指向整形的指针. int (*f)(); 两对括号,第二对括号是函数调用操作符,但第一对括号只起到聚组的作用. f为一个函数指针,它所指向的函数返回一 ...

  5. PAT 1036 Boys vs Girls[简单]

    1036 Boys vs Girls (25 分) This time you are asked to tell the difference between the lowest grade of ...

  6. k8s-离线安装k8s

    1.开始 目标 coreos的igniton.json有很强的可配置性,通过安装时指定集群配置的ignition.json, 安装完成后打开https://{{Master_IP}}:6443/ui直 ...

  7. XE6移动开发环境搭建之IOS篇(2):安装虚拟机(有图有真相)

    XE6移动开发环境搭建之IOS篇(2):安装虚拟机(有图有真相) 2014-08-15 22:04 网上能找到的关于Delphi XE系列的移动开发环境的相关文章甚少,本文尽量以详细的内容.傻瓜式的表 ...

  8. 130. Surrounded Regions(周围区域问题 广度优先)(代码未完成!!)

    Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A reg ...

  9. 101. Symmetric Tree(判断二叉树是否对称)

      Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For ...

  10. 【转】使用DataConnectionDialog在运行时设置数据源连接字符串

    介绍: DataConnectionDialog 类: 打开“数据连接”对话框,获取用户选择的数据连接信息. 命名空间为:Microsoft.Data.ConnectionUI 所在程序集:Micro ...