...
This compliant solution uses a try-with-resources statement which will guarantee that both br
and bw
are closed, irrespective regardless of any exceptions being potentially thrown during the close operations.
...
This noncompliant code example uses an ordinary try-finally block to try to close a resource. However, if there is an exception thrown both during the processing of the input and another exception thrown when closing the Bufferedreader
br
, then the exception thrown as a result of processing the input will be lost, and important information about that exceptional circumstance may be missed.
...