Welcome to the Ranch
Paweł Michalak. You are correct about the Exception from the
finally block.
What you want is this sort of thing:
That ensures that if you can actually open your reader, it is closed, because the
finally block is always executed whether or not the
try suffers an Exception. Since the close() method declares a checked Exception, having it inside the outer
try ensures that Exception is handled too.
I have added lots of comments to try and make the control flow easier to see. Probably more than you would want in real life. The format for file streams, data input streams, writers, etc, is very similar.