I am very confused as to why do I need to need to put the clean-up code like closing streams in a finally
block.
I\'ve read that the code in finally<
after the finally block runs rest of the method continues
This is only true if there was no exception caught. If an exception happens inside the try block the catch block will be executed (if there is one for this exception), the finally block will be executed, and then control is given to the caller of the method if the catch block throws the exception further, without running any further code in this method.
EDIT: clarify that catch would have to return of course, and not just eat the exception.