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;


}

spring加载properties配置文件的更多相关文章

  1. 使用Spring加载properties配置文件.md

    背景 类似于datasource.properties之类的配置文件,最初通过Java的Properties类进行处理.这种方式有许多弊端,如每次都需要读取配置文件:若将Properties作为成员变 ...

  2. Spring加载Properties配置文件的三种方式

    一.通过 context:property-placeholder 标签实现配置文件加载 1) 用法: 1.在spring.xml配置文件中添加标签 <context:property-plac ...

  3. Spring加载properties文件的两种方式

    在项目中如果有些参数经常需要修改,或者后期可能需要修改,那我们最好把这些参数放到properties文件中,源代码中读取properties里面的配置,这样后期只需要改动properties文件即可, ...

  4. Java加载Properties配置文件工具类

    Java加载Properties配置文件工具类 import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; ...

  5. 加载Properties配置文件

    /** * 加载Properties配置文件 * * @author ZhangHaiNing * @param file 要读取的文件 * @return */ public static Prop ...

  6. Spring加载properties文件的属性的值

    要使用配置文件的值首先在spring.xml配置加载properties文件 <context:property-placeholder location="classpath:ife ...

  7. spring加载属性配置文件内容

    在spring中提供了一个专门加载文件的类PropertyPlaceholderConfigurer,通过这个类我们只需要给定需要加载文件的路径就可以 通过该类加载到项目,但是为了后面在程序中需要使用 ...

  8. Spring加载xml配置文件的方式 ApplicationContext

    大家都知道Java读普通文件是通过Basic I/O 中的InputStream.OutStream.Reader.Writer 等实现的.在spring 框架中,它是怎样识别xml这个配置文件的呢? ...

  9. Spring加载XML配置文件

    原创链接:http://www.cnblogs.com/yanqin/p/5282929.html(允许转载,但请注明原创链接) BeanFactory加载单个文件 当使用beanfactory去获取 ...

随机推荐

  1. 模型-视图-控制器 (MVC)

    在MVC中 ,模型代表数据和业务规则, 视图包含了用户界面元素,例如文本,表单等 控制器则管理模型和视图中的通信

  2. Python进阶(面向对象编程基础)(二)

    1.初始化实例属性 #!/usr/bin/env python # -*- coding:utf-8 -*- __author__ = 'ziv·chan' #定义Person类的__init__方法 ...

  3. c#序列化反序列化工具(json,binary,xml)

    using System; using System.Text; using System.IO; using System.Runtime.Serialization.Formatters.Bina ...

  4. IOS设计模式学习(18)模板方法

    1 前言 模板方法模式是面向对象软件设计中一种非常简单的设计模式.其基本思想是在抽象类的一个方法定义“标准”算法.在这个方法中调用的基本操作由子类重载予以实现.这个方法成为“模板”.因为方法定义的算法 ...

  5. [React Testing] Reusing test boilerplate

    Setting up a shallow renderer for each test can be redundant, especially when trying to write simila ...

  6. C编程风格.

    C语言编程风格. 关于编程风格,不同书上有不同规范,不同公司都有自己的一套定义.根据自己的编程习惯做个简要说明. 1.变量定义 在定义变量时,前缀使用变量的类型,之后使用表现变量用途的英文单词或单词缩 ...

  7. Find命令简介

    Find命令主要用于目标的搜索,尽量做到少使用,因为find会消耗大量的系统资源. 使用该命令时,需要避开服务器运行高峰期,最好在指定的小范围内进行搜索,不要轻易使用全盘搜索. Find命令常用的参数 ...

  8. 网页JavaScript1

    DOM的操作 windows对象操作 属性: opener,打开当前窗口的源窗口,首次启动 是null. dialogArgument,对话框的返回值 子对象: history , location ...

  9. Chrome: Shockwave Flash isn't responding

    这个问题问 Google 解决得比较快,百度里尽是转载党的东西! 1. 到 chrome://settings/content 找到 Plug-ins 项目 2. 点击 Plug-ins 里的 Exc ...

  10. PagerSlidingTabStrip的使用

    布局 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:too ...