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;
    }

  • 相关阅读:
    grub menu from pygrub
    Unix调试的瑞士军刀:lsof
    Quantum & r2q
    Linux TC基于CBQ队列的流量管理范例
    hfsc
    用bash做个tcp客户端
    [转]HFSC Scheduling with Linux
    [转]如何判断 Linux 是否运行在虚拟机上
    TSO
    使用VS2008进行WEB负载测试
  • 原文地址:https://www.cnblogs.com/riskyer/p/3239091.html
Copyright © 2011-2022 走看看