Java 7 try-with-resources: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 13: Line 13:


<syntaxhighlight lang='java'>
<syntaxhighlight lang='java'>
try (BufferedReader br = new BufferedReader(new FileReader(file))) {


    // ...


}
catch(IOException e) {
    // ...
}
</syntaxhighlight>
</syntaxhighlight>



Revision as of 22:07, 7 June 2018

External

Internal

Overview

Local variables declared as resources in a try-with-resources statement are implicitly final.

try (BufferedReader br = new BufferedReader(new FileReader(file))) {

    // ...

}
catch(IOException e) {

    // ...

}

AutoCloseable

TODO