zoukankan      html  css  js  c++  java
  • spring加载properties配置文件

    public static void main(String[] args){
     
     String path="E:/workspace/bocMarketData/src/config/PeriodCode.properties";
     try {
    Map<String,String> periodCodeMap =readConfigForMap(path);
    Set<String> set1 = periodCodeMap.keySet(); 
     for (String s:set1) {
     System.out.println(s+","+periodCodeMap.get(s));
     }

    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    /**
    * 读取文件,生成 Map<String,String>,左边为key 右边为value
    * @param path
    * @return
    * @throws Exception
    */
    public static Map<String,String> readConfigForMap(String path) throws Exception{
    BufferedReader bf=null;
    try{
    InputStream in = new FileInputStream(new File(path));
    // path  E:/workspace/eDealingV3.0_eTof/src/conf/config/institutionl_IP_Config.properties
    Reader reader = new InputStreamReader(in);
      bf=new BufferedReader(reader);
      
    }catch(Exception e){
    e.getMessage();
    }
     
    String row=null;
    Map<String,String> sMap = new HashMap<String, String>();
    while(null!=(row=bf.readLine())){
    if(!row.equals("")){
    if(row.startsWith("#")){
    continue;
    }
    String key = row.substring(0, row.indexOf("="));
    String value = row.substring(row.indexOf("=")+1,row.length());
    sMap.put(key, value);
    }
    }
    bf.close();
    return sMap;
    }

  • 相关阅读:
    JS之事件及冒泡
    DOM读取和修改内联样式
    dom查询与修改的一些常用方法
    js修改this指向的三种方法(call,bind,apply)
    JS原型概念
    JS创建对象
    JS的this(谁调用就指向谁)
    变量声明提前与函数声明提前
    JS对象创建
    正则应用之数据采集房屋网站信息
  • 原文地址:https://www.cnblogs.com/riskyer/p/3239091.html
Copyright © 2011-2022 走看看