java配置文件类写入键值对并读出

class FilesDemo2{
public static void main(String[] args){

try(FileOutputStream fos = new FileOutputStream("D:\\test.properties");
FileInputStream fis = new FileInputStream("D:\\test.properties")
){
Properties p = new Properties();
p.setProperty("username", " XXX");
p.setProperty("password ","123456");
p.setProperty("sex"," X");
p.setProperty("brithday"," 2000.5.18");
p.store(fos,"");
Properties p1 = new Properties();
p1.load(fis);
System.out.println(p1);

}catch(IOException e ){
e.printStackTrace();
}
}
}

原文地址:https://www.cnblogs.com/01aa/p/6735672.html