Properties 类

 定义

   表示一个持久的集,可以存在流中   或者从流中加载

特点

  是Hashtable子类  map集合方法都可以用

第一种:

public class PropertiesDemo1 {
public static void main(String[] args) throws Exception{
Properties p = new Properties();
BufferedOutputStream in = new BufferedOutputStream(new FileOutputStream("a.properties"));
p.setProperty("a","yang");
p.setProperty("b","han");
p.setProperty("c","gao");
p.store(in,null);
in.close();
}
}
第二种:
public static void fun3() throws Exception{
Properties p = new Properties();
p.setProperty("name","韩高峰");
p.setProperty("age","16");
p.setProperty("sex","性感男");
p.setProperty("adds","太康");
p.setProperty("email","meng@.com");
FileWriter f = new FileWriter("t.properties");
p.store(f,null);
f.close();
}
原文地址:https://www.cnblogs.com/Y-mmeng/p/10606511.html