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
Post a Comment