testfilereader.java
来自「很好的程序欢迎大家来下载。初学者很有用的。」· Java 代码 · 共 31 行
JAVA
31 行
import java.io.*;
public class TestFileReader {
public static void main(String[] args) {
FileReader input = null;
try {
// Create an input stream
input = new FileReader("temp.txt");
int code;
// Repeatedly read a character and display it on the console
while ((code = input.read()) != -1)
System.out.print((char)code);
}
catch (FileNotFoundException ex) {
System.out.println("File temp.txt does not exist");
}
catch (IOException ex) {
ex.printStackTrace();
}
finally {
try {
input.close(); // Close the stream
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?