KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In readFileMethod1 , an IOException is explicitly catched before throwing it at the method level to ensure that the finally block is executed. However, is it neccessary to catch the exception? If I remove the catch block, shown in readFileMethod2 , does the finally block get executed as well? private void readFileMethod1() throws IOException { try { // do some IO stuff } catch (IOException ex) { throw ex; } finally { // release resources } } private void readFileMethod2() throws IOException { try { // do some IO stuff } finally { // release resources } }
Tags (comma-separated)
Save Edits
Cancel