// 根据key读取value
public void readValue(String filePath, String key) {
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream(filePath));
//Thread.currentThread().getContextClassLoader().getResourceAsStream("eop.properties");
props.load(in); // 从输入流中读取属性列表(键和元素对)
String value = props.getProperty(key);
}
// 读取properties的全部信息
public static void readProperties(String filePath) {
Properties props = new Properties();
InputStream in = new BufferedInputStream(new FileInputStream(filePath));
props.load(in);
Enumeration en = props.propertyNames();
while (en.hasMoreElements()) {
String key = (String) en.nextElement();
String value = props.getProperty(key);
}
}