📄 filer.java
字号:
package myutilities;
import java.io.*;
import javagently.*;
public class Filer {
/* The Filer class by J M Bishop June 2000
* ---------------------- Java 1.2
* based on the FileMan class
* from June 1997
*
* Provides for a file to be opened, with five tries at a
* correct file name.
* Illustrates the use of exceptions in for-try loops..
*/
public static Stream open (String filename) throws IOException {
Stream in = new Stream (System.in);
for (int count = 0; count < 5; count ++) {
try {
return new Stream(filename, Stream.READ);
} catch (FileNotFoundException e) {
System.out.println(filename+" does not exist.");
if (count < 4) {
System.out.println("Try again");
}
filename = in.readString();
}
}
throw new FileNotFoundException ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -