mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-04 17:20:55 +07:00
24 lines
702 B
HTML
24 lines
702 B
HTML
<html>
|
|
<body>
|
|
Reports <code>try</code>-<code>finally</code> statements that can use Java 7 Automatic Resource Management,
|
|
which is less error-prone.
|
|
<p>A quick-fix is available to convert a <code>try</code>-<code>finally</code>
|
|
statement into a <code>try</code>-with-resources statement.</p>
|
|
<p><b>Example:</b></p>
|
|
<pre><code>
|
|
PrintStream printStream = new PrintStream(fileName);
|
|
try {
|
|
printStream.print(true);
|
|
} finally {
|
|
printStream.close();
|
|
}
|
|
</code></pre>
|
|
<p>A quick-fix is provided to pass the cause to a constructor:</p>
|
|
<pre><code>
|
|
try (PrintStream printStream = new PrintStream(fileName)) {
|
|
printStream.print(true);
|
|
}
|
|
</code></pre>
|
|
<!-- tooltip end -->
|
|
</body>
|
|
</html> |