📄 showfile.java
字号:
//创建FileInputStream对象,读取一个文本文件,并输出其内容。
import java.io.*;
class ShowFile {
public static void main(String args[])
throws IOException
{
int i;
FileInputStream opfis;
//捕获异常,判断文本文件是否存在
try {
opfis = new FileInputStream("test11_1.txt");
} catch(FileNotFoundException exc)
{
System.out.println("File Not Found");
return;
}
// 从文本文件读取数据
do {
i = opfis.read();
if(i != -1) System.out.print((char) i);
} while(i != -1);
opfis.close();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -