62,620
社区成员
发帖
与我相关
我的任务
分享
public static void main(String args[]) throws IOException {
Hashtable<String, String> table = new Hashtable<String, String>();
table.put("username", "root");
table.put("username", "zhangs");
Iterator<String> keyIterator = table.keySet().iterator();
while(keyIterator.hasNext()) {
String key = keyIterator.next();
System.out.println(key + "=" + table.get(key));
}
}
//根据key读取value
public static String readValue(String filePath,String key) {
Properties props = new Properties();
try {
InputStream in = new BufferedInputStream (new FileInputStream(filePath));
props.load(in);
String value = props.getProperty (key);
System.out.println(key+value);
return value;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}