1、存储
Properties properties = new Properties();
properties.put("aaa", "111");
properties.put("bbb", "222");
properties.put("ccc", "333");
properties.put("ddd", "444");
File file = new File("properties/test1.property");
FileOutputStream fileOutputStream = new FileOutputStream(file);
properties.store(fileOutputStream, "test1");
fileOutputStream.close();
2、获取
Properties properties1 = new Properties();
FileInputStream fileInputStream = new FileInputStream(file);
properties1.load(fileInputStream);
fileInputStream.close();
properties1.list(System.out);
for (Object o : properties1.keySet()) {
System.out.println(properties1.getProperty(o.toString()));
}