eclipse之java 7 try-with-resource语法错误
当我尝试使用新的 Java 7 try-with-resource 时,我在 Eclipse 中的 try(BufferReader.. 行中收到“ token ”语法错误“,{预期”。(下面的代码片段)这是直接从java nio教程中复制过来的 http://download.oracle.com/javase/tutorial/essential/io/file.html
我已将构建路径配置到最新的 java7 位置,并且我知道它已正确配置,因为我正在使用其他 java.nio 功能,如 Path 和 SimpleFileVistor,没有任何问题。有什么建议么? 谢谢!
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;
请您参考如下方法:
请检查项目属性中的编译器合规级别,它应该是 1.7。您还使用哪个版本的 Eclipse?仅在最近的版本中提供支持 - 请参阅 http://thecoderlounge.blogspot.com/2011/07/java-7-support-in-eclipse-371-38-42.html
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。



