import java.io.FileReader; import java.io.IOException; import java.nio.file.FileVisitResult; public class Demo03Read { public static void main(String[] args) throws IOException {//字符流读取字符 FileReader fr=new FileReader("F:\basic\untitled13\src\it\cast\day15\demo01\2.txt"); /* int len=0; while ((len=fr.read())!=-1){ System.out.print((char) len); }*/ int len=0; char[] cs=new char[1024]; while ((len=fr.read(cs))!=-1){ System.out.println(new String(cs,0,len)); } fr.close(); } }