1.该流一般用于配置文件。
(1)load(io流):把配置文件加载进内存。
(2)store(io流,说明):把内容写入配置文件。
2.Properties 类表示了一个持久的特性集合。
(1)Properties 可保存到流中或从流中加载。
(2)Properties集合是唯一和IO流相结合的集合.
import java.io.*;
import java.util.Properties;
public class demo {
public static void main(String[] args) throws IOException {
mystore();
// myload();
}
private static void myload() throws IOException {
Properties prop = new Properties();
// FileReader fr = new FileReader("I:java.txt");
FileReader fr = new FileReader(new File("I:java.txt"));
prop.load(fr);
System.out.println(prop);
}
private static void mystore() throws IOException {
Properties prop = new Properties();
prop.setProperty("0001","林青霞");
prop.setProperty("0002","张曼玉");
prop.setProperty("0003","王祖贤");
FileWriter fw = new FileWriter("I:java.txt");
//store(fw,comments)comments是说明内容
prop.store(fw,"你好呀fjoewijgfeiorgfej");
fw.close();
System.out.println(prop);
}
}