字符输入流

 1     public static void main(String[] args) throws Exception {
 2         //  定义一个字符输入流与文件相通
 3         Reader re = new FileReader("src/test.txt");
 4         //  用循环每次读取一个字符数组的数据
 5         char[] ch = new char[1024];
 6         int len;
 7         while ((len = re.read(ch)) != -1){
 8             String st = new String(ch, 0, len);
 9             System.out.println(st);
10         }
11     }

 

posted @ 2024-01-28 03:20  小※兽  阅读(5)  评论(0)    收藏  举报