标签:style class blog code java color
String filePath="src/cn/ac/iscas/pebble/ufe/conf/id.properties"; InputStream in = new BufferedInputStream(new FileInputStream(filePath)); int i = 0; Properties p = new Properties(); p.load(in);
p.getProperty(key);
还有一个方式如下:
public class ConfigUtils { private static final ResourceBundle baseBundle = ResourceBundle.getBundle("cn/ac/iscas/pebble/ufe/conf/id"); public static String getValue(String key) { return baseBundle.getString(key).trim(); }
首先 id所在的大目录必须在classpath下。如下所示:
Navigator下查看.classpath文件:
<?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/>
…………
Java 读取配置文件 Properties,布布扣,bubuko.com
标签:style class blog code java color
原文地址:http://www.cnblogs.com/dorothychai/p/3810213.html