package JavaSE.Lesson18;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class ReaderDemo {
public static void main(String[] args) {
String str = "e:\\Demo02.txt";
FileReader fr= null;
char[] buf = new char[8];
int dataLen;
try {
fr = new FileReader(str);
//这个返回的是数值的值
while ((dataLen=fr.read(buf))!=-1){
System.out.print(new String(buf,0,dataLen));
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fr!=null){
try {
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
标签:fr,java,String,fileReader,dataLen,循环,io,2023,import
From: https://www.cnblogs.com/RUI2022/p/17177148.html