黑马程序员技术交流社区
标题:
读取properties 配置文件 返回属性值
[打印本页]
作者:
苗超维
时间:
2016-1-21 10:18
标题:
读取properties 配置文件 返回属性值
:Properties的概述
* Properties 类表示了一个持久的属性集。
* Properties 可保存在流中或从流中加载。
* 属性列表中每个键及其对应值都是一个字符串。
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream(
filePath)); //filePath 为配置文件的地址
props.load(in);
String value = props.getProperty(key);
System.out.println(key +"键的值是:"+ value);
return value;
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2