Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#917 Java 7 Indention for Try-with-Resources

open
nobody
None
5
2011-09-05
2011-09-05
Mathias Ricken
No

Try-with-resources is indented badly if the auto-closables are split into more than one line. The body of the try construct is indented too deeply.

// badly indented
public static void tryWithResources2(String f) {
try (InputStream is = new FileInputStream(new File(f));
InputStream is2 = new FileInputStream(new File(f))) {
is.read();
}
catch(IOException e) {
e.printStackTrace();
}
}

Discussion