// 根據(jù)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);
}
}