ioexception.java
来自「实例精华」· Java 代码 · 共 28 行
JAVA
28 行
package EXception;
import java.io.*;
public class IOEXception {
public static void main(String[] args) {
IOEXception io = new IOEXception();
try {
/*FileInputStream(String s) 这个构造中的参数为文件的路径
其中相对路径用e:\\hl.txt,绝对路径用e:/hl.txt来表示*/
FileInputStream fis = new FileInputStream("e:/hl.txt");
int i = 0;
int d = fis.read();
while ((i=d) != -1) {
System.out.print((char) i);
}
//使用完后需要将fis关闭,以节省系统资源
fis.close();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?