1.字符流
1>字符流是字节流的包装
2>字符输出流: 能够以字符的方式输出, 需要fiush()
如图:
代码如下:
File file = new File("D:/非凡/feifan/apple1.txt");
Writer out = new FileWriter(file);
out.write("hello");
out.flush();
out.write("哀民生之多艰");
out.flush();
out.write("奔流到海不复回");
out.flush();
3>字符输入流:
如图所示:
代码如下:
File file = new File("D:/非凡/feifan/apple2.html");
Reader in = new FileReader(file);
BufferedReader reader = new BufferedReader(in);
String line = null;
while((line = reader.readLine())!=null){
System.out.println(line);
}
reader.close();
2. HashTable和HashMap
HashMap:允许左右null,但hashTable不允许任何null
3.Properties
属性,读取文件格式,key=value
配置文件:xxxx.properties
4. 对象流:存储对象
通过接口,使得对象有序列化