Bootstrap

读取properties文件中的key和value

public static Map<String, String> map=new HashMap<String, String>();
public void init(){
    Properties prop = new Properties();
    try {
        // 读取属性文件systemparameter.properties 


        //InputStream in = new BufferedInputStream(new FileInputStream("/home/bgusr01/payment/accountChange/config/prop.properties"));		//服务器地址
        InputStream in = new BufferedInputStream(new FileInputStream("D:/dx_sh_lixiang/myeclipse/wlwtzAccount/src/Interface.properties"));  //本地测试地址D:\wicerd\tiyuGitLabWorkSpace\accountChange\src
        //InputStream in = new BufferedInputStream(new FileInputStream("/home/bgusr01/payment/iotBillSync/config/prop.properties"));
        //System.out.println("配置文件路径"+Thread.currentThread().getContextClassLoader().getResource("").getPath()+"/prop.properties");
        prop.load(in); // /加载属性列表
        Iterator<String> it = prop.stringPropertyNames().iterator();
        while (it.hasNext()) {
            String key = it.next();
            map.put(key, prop.getProperty(key));
            //System.out.println(key + ":" + prop.getProperty(key));
            System.out.println("update svc_common_info set char_value='"+ prop.getProperty(key)+"'  where parameter_name='"+key+"';" );
        }
        in.close();
    } catch (Exception e) {
        System.out.println(e);
    }
}
;