InputStreamWrite:字符流

两种读取方法如下所示:

package cn.zll.demo;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class WriteDemo {
    public static void main(String[] args) throws IOException {


        InputStreamReader reader=new InputStreamReader(new FileInputStream("out.txt"));

//      int len=0;
//      while((len=reader.read())!=-1){
//          
//          System.out.print((char)len);
//          
//          
//      }
        int len=0;
        char[] b=new char[1024];
        while((len=reader.read(b))!=-1){

            System.out.println(new String(b, 0, len));

        }



    }

}

你可能感兴趣的:(java)