1. Reader/Writer(字符流的输入和输出流,只是相对java文件而言)
1.1 //能够用文本编辑器打开文件,不乱码就是字符文件
//能够用文本编辑器打开乱码,就是字节文件
1.2 FileWrite
fw.write(char); //写一个字符
fw.write(char[]); //写字符数组
1.3 BufferedReader(字符输入缓冲流)
BufferedRead br = new BufferedRead(new FileReader("文件路径"));
String str = br.readLine(); //读取一行字符
1.4 BufferedWriter (字符输出缓冲流)
BufferedWriter bw = new BufferedWriter (new FileWriter ("文件路径"))
bw.writer(字符串);
缓冲流不能单独存在
2. DateInputStream/DateOutputStream
2.1 读写字符文件
BufferedReader br = new BufferedReader (new FileReader(文件));
BufferedWriter bw = new BufferedReader (new FileWriter (文件 boolear));
2.2 读写字节文件
DateInputStream dis = new DateInputStream (new FileInputStream(文件));
DateOutputStream dos = new DateOutputStream (new FileOutputStream(文件));
2.3 读取整个字符文件
String str = null;
while((str=br.readLine())!=null){
system.out.println(str)
}
2.4 读取整个字节文件
int b;
while((b=dis.read())!=-1)
system.out.println(b)