package com.kk.review;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class CharStream {
/*
* Reader
BufferedReader
LineNumberReader
CharArrayReader
FilterReader
PushbackReader
InputStreamReader //实现字节流转化为字符流
FileReader
PipedReader
StringReader
Writer
BufferedWriter
CharArrayWriter
FilterWriter
OutputStreamWriter//实现字节流转化为字符流
FileWriter
PipedWriter
PrintWriter
StringWriter
*/
public static void main(String[] args) {
try {
FileInputStream file=new FileInputStream("1.txt");//字节流
InputStreamReader isr=new InputStreamReader(file);//将字节流转为字符流
BufferedReader br=new BufferedReader(isr);//可以缓冲的字符流类
System.out.println(br.readLine());
file.close();
FileOutputStream fos=new FileOutputStream("1.txt"); //字节流
OutputStreamWriter osw=new OutputStreamWriter(fos);//将字符流转为字节流
BufferedWriter bw=new BufferedWriter(osw);//带缓冲的字符流类
bw.write("哈哈");
fos.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}