The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
September 2000

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

TRY-CATCH USE

Posted by Dinesh on September 20, 2000 at 7:01 PM

I am confused that how to use try-catch best way.
Say I am using it in my one method.
Then I have options like.
1. Write whole function in one try-catch block.
2. Write many try-catch blocks and group few sentences.
3. Write one try catch block for whole code and use other try-catch in side of outer try-catch blocks. That is nested try-catch blocks.
And suppose I want to close my file before returning from function.
I can write close file statement in finally block.
But here again I have to write try-catch because close file throws exception.
How to deal with this?
Thank you very much in advance.





Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us