public class Demo_properties {
public static void main(String[] args) throws IOException {
//Properties是Hashtable的子类(即Map的子类)
//写数据
/*Properties ppt = new Properties();
ppt.put("name","金苹果");
ppt.put("info","讲述了苹果种植的过程");
FileWriter fw = new FileWriter("D:/book.properties");
ppt.store(fw,"存储的图书");
fw.close();*/
//读取数据
Properties ppt = new Properties();
FileReader r = new FileReader("D:/book.properties");
ppt.load(r);
System.out.println(ppt.get("name"));
//getProperty()是Properties类特有的,和get()功能一样
System.out.println(ppt.getProperty("info"));
}
}



1437

被折叠的 条评论
为什么被折叠?



