All the clean up code is written inside the finally block because there are more than one catch clauses so each each then requires its own copy of the cleanup code.
you allocated a network socket or opened a file somewhere in the guarded region,
each exception handler would have to close the file or release the socket. That
would make it too easy to forget to do cleanup, and also lead to a lot of redundant
code. To address this problem, Java offers the finally block.