java字符流读取


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

public class InputStreamReader1 {
    public static void main(String[] args) throws IOException {
        InputStreamReader streamReader = new InputStreamReader(new FileInputStream("E:\\Workpace\\abc.txt"));
//        int b;
//        while ((b = streamReader.read()) != -1){
//            System.out.print(b);
//        }
        char[] bytes = new char[1024];
        int len;
        while((len = streamReader.read(bytes)) != -1){
            System.out.print(new String(bytes,0,len));
        }
        streamReader.close();
    }
}


posted @ 2021-05-01 10:53  code-G  阅读(98)  评论(0编辑  收藏  举报