FileReader(字符流) FileInputStream(字节流) BufferReader(带有缓冲区的字符流)

1) File file = new File ("hello.txt"); 

//使用字节流

FileInputStream in=new FileInputStream(file); 


2) File file = new File ("hello.txt"); 

//使用字节流,

FileInputStream in=new FileInputStream(file); 

//然后使用字节流字符流的桥梁,把字节流转换为字符流

InputStreamReader inReader=new InputStreamReader(in); 

//使用带有缓冲区的字符流

BufferedReader bufReader=new BufferedReader(inReader); 

3) File file = new File ("hello.txt"); 

//使用字符流

FileReader fileReader=new FileReader(file); 

//使用带有缓冲区的字符流

BufferedReader bufReader=new BufferedReader(fileReader);

你可能感兴趣的:(FileReader(字符流) FileInputStream(字节流) BufferReader(带有缓冲区的字符流))