Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2007, 07:16 PM
Member
 
Join Date: Nov 2007
Posts: 97
javaplus is on a distinguished road
when to use try...catch
When coding, there are some statements that need try .. catch block otherwise complier gives error and forces the coder to write such statements under try ... catch block.

How can I know, which statements should be written under try...catch block

Currently, when complier gives error, I then put that statement under try...catch.

Thanx.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-18-2007, 07:40 PM
Senior Member
 
Join Date: Jul 2007
Posts: 1,189
hardwired is on a distinguished road
That seems to be the general practice - add the try-catch blocks where indicated by the compiler. The javadocs is/are the place to find out what is required, viz, the Method Detail section for the method(s) in question.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-18-2007, 09:52 PM
Senior Member
 
Join Date: Nov 2007
Posts: 115
ravian is on a distinguished road
Thanks. Got the idea.

I checked Java Docs and found following signature for FileOutStream constructor:

Code:
public FileOutputStream(File file) throws FileNotFoundException
which means we have to write in under try...catch block.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
try catch!? Joe2003 Advanced Java 2 01-28-2008 08:51 PM
Try Catch issue curtis_fraser Advanced Java 2 12-14-2007 12:04 AM
Try Catch Renegade85 New To Java 4 12-03-2007 05:10 PM
try...catch block javaplus New To Java 3 11-06-2007 08:53 PM
Use try and catch zoe New To Java 2 07-25-2007 08:50 PM


All times are GMT +3. The time now is 04:57 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org