properties
概述
1.该类位于java.util包下.需要导包
2.此类是线程安全的:多个线程可以共享单个 Properties 对象而无需进行外部同步
3.该类是Hashtable的子类,该类中有方法可以操作io
4.该类没有标注泛型但是都使用String类型
5.该类创建的文件后缀名请使用.properties
构造方法
Properties prop = new Properties();
主要方法
1.store()将集合中数据以键值对的方式存储到硬盘
FileWriter fw = new FileWriter("demo.properties");Properties prop = new Properties();prop.put("1","张三");prop.store(fw,null);
2.load()将文件以键值对的方式读取到集合中
FileReader fr = new FileReader("demo.properties");Properties prop = new Properties();prop.load(fr);