java - Is it okay to use try catch inside finally? -


I am using a buffer author and my code, finally closes the author in the block. My code is the same.

  ........... bufferdirector buffed wight = null; Hold {TheBufferedWriter = ..... ......... .....} (IOException anException) {....} Finally {tryBufferedWriter.close (); } Hold (IOException anException) {anException.printStackTrace (); }}  

I have to use the capture inside the clean up code because the buffarder can throw an IOException, I do not want to throw this exception to Calling Methos. Is it a good practice to finally use a try hold? If not, what is the alternative? Please suggest.

Regards, Himal

Use this to be done in a good way USA A native tribe of It keeps your code organized and eliminates some boilerplate which is contained in Java.

You then become the codes:

  BufferedWriter theBufferedWriter = null; {TheBufferedWriter = ... ...} Catch (IOException anException) {...} Finally {IOUtils.closeQuietly; }  

Very good and more expressive.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -