Java 教程是为 JDK 8 编写的。本页中描述的示例和实践未利用在后续版本中引入的改进。
try {
} finally {
}
catch (Exception e) {
}
try {
} catch (Exception e) {
} catch (ArithmeticException a) {
}
int[] A;
A[0] = 0;classes.zip 或 rt.jar。)end of stream 标记的末尾。end of stream 标记之后,程序尝试再次读取流。readList 方法添加到 ListOfNumbers.java。此方法应从文件中读取 int 值,打印每个值,并将它们附加到 vector 的末尾。你应该捕获所有适当的错误。你还需要一个包含要读入的数字的文本文件。cat 方法,以便进行编译。
public static void cat(File file) {
RandomAccessFile input = null;
String line = null;
try {
input = new RandomAccessFile(file, "r");
while ((line = input.readLine()) != null) {
System.out.println(line);
}
return;
} finally {
if (input != null) {
input.close();
}
}
}