Java finally block and throws exception at method level -


in readfilemethod1, ioexception explicitly catched before throwing @ method level ensure finally block executed. however, neccessary catch exception? if remove catch block, shown in readfilemethod2, finally block executed well?

private void readfilemethod1() throws ioexception {     try {         // io stuff     } catch (ioexception ex) {         throw ex;     } {         // release resources     } }  private void readfilemethod2() throws ioexception {     try {         // io stuff     } {         // release resources     } } 

the finally still gets executed, regardless of whether catch ioexception. if catch block rethrow, not necessary here.


Comments

Popular posts from this blog

sql - text truncated using perl DBI insert -

c++ - Is it possible to compile a VST on linux? -

php - Pass object by reference or value -