当我尝试使用新的 Java 7 try-with-resource 时,在 Eclipse 中的 try(BufferReader.. 行中出现“令牌语法错误”(“, { expected”)。这是直接复制的来自 java nio 教程http://download.oracle.com/javase/tutorial/essential/io/file.html
我已将构建路径配置为最新的 java7 位置,并且我知道它已正确配置,因为我正在使用 Path 和 SimpleFileVistor 等其他 java.nio 功能而没有任何问题。有什么建议么?谢谢!
try(BufferedReader reader = Files.newBufferedReader(file, charset)) {
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}catch (IOException x) {
System.err.format("IOException in reading " + file.getFileName().toString()+ x);
}
return testCaseNames;