package JavaSE.Lesson18;
import java.io.FileReader;
import java.io.IOException;
public class ReaderDemo02 {
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())!=-1){
System.out.print((char)dataLen);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fr!=null){
try {
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
标签:fr,fileReader,char,printStackTrace,dataLen,循环,IOException,2023,FileReader
From: https://www.cnblogs.com/RUI2022/p/17177150.html