首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

运用InputStream流读取.properties配置文件

2012-09-14 
使用InputStream流读取.properties配置文件?使用InputStream流读取.properties配置文件:/** * 读取配置文

使用InputStream流读取.properties配置文件

?

使用InputStream流读取.properties配置文件:

/** * 读取配置文件 *  */private void getProperties(){//test.properties文件默认在src/config目录中下;URL url = getClass().getClassLoader().getResource("config/test.properties");InputStreamReader inputStreamReader = null;Properties properties = new Properties();try {    InputStream inputStream = url.openStream();    inputStreamReader = new InputStreamReader(inputStream);    //加载配置文件;    properties.load(inputStreamReader);    //根据key获取value;    String value = properties.getProperty("versionName");    System.out.println(value);} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}}

???

?

热点排行