Map<String,String> map = new HashMap<>();
map.put("dilei","123456");
map.put("wuyanz","654321");
Properties p = new Properties();
p.putAll(map);//将map集合里的键值对信息拷贝倒p对象中
//将p对象中的键值对信息存入F:\JavaProject\Project\src\p.properties此路径中,属性文件的后缀必须是properties
p.store(new FileWriter("F:\JavaProject\Project\src\p.properties"),"give me 100");
Properties p1 = new Properties();
//从F:\JavaProject\Project\src\p.properties路径中加载键值对信息
p1.load(new FileReader("F:\JavaProject\Project\src\p.properties"));
System.out.println(p1);
String sr = p1.getProperty("dilei");//根据键取值 getProperty就是getKey,只是套了一层王八壳
System.out.println(sr);
Properties还有很多方法