Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2008, 07:55 PM
Member
 
Join Date: Apr 2008
Posts: 3
Rep Power: 0
aytidaalkuhs is on a distinguished road
Default Where does the exception go?
I was doing some file handling recently and used the read() method of the FileInputStream class. The read() method throws an IOException. I came across code (and used it as well) that looks like the snippet below.
Code:
class fileRead{
public static void main(String []a) throws IOException {
//do file handling here and call read as well
}
}

Now, what i want to know is that who handles the IOException? Is it the JVM? If yes, how does it do it. If no, please help.

waiting...
aytidaalkuhs
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 04-06-2008, 08:33 PM
Java Tip's Avatar
Moderator
 
Join Date: Nov 2007
Posts: 1,691
Rep Power: 5
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Default
You are just throwing it. That means nobody handles it.

If you write the code like this. You can handle it yourself:

Code:
class fileRead{
public static void main(String []a) {

  try {
    //do file handling here and call read as well
  } catch(IOException e) {

    // handle your exception here
    e.printStackTrace();

  }
}
}
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 04-07-2008, 11:56 AM
DonCash's Avatar
Moderator
 
Join Date: Aug 2007
Location: London, UK
Posts: 241
Rep Power: 4
DonCash will become famous soon enoughDonCash will become famous soon enough
Default
Hey.

Read this Sun Java Tutorial on Exceptions. Its very informative:

Lesson: Exceptions (The Java™ Tutorials > Essential Classes)
__________________
Did this post help you? Please me!
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-07-2008, 03:24 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 7,513
Rep Power: 11
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Yes, it's. What is the best thing is handling the Exceptions. Normally what I have done is, catch all exceptions and put it into a log. So anytime latter I can check my error.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
Someone helped you? their helpful post.
Help:Forums FAQ|How To Ask Questions The Smart WayResources:The Java Tutorials|Glossary for Java|NetBeans IDE|Sun DownloadsWeb:WritOnceTips:Is your IDE the best?|Which Application Server?
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

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

BB 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
Need help on Exception Deon New To Java 7 02-11-2010 06:46 PM
exception Oktam New To Java 2 03-23-2008 08:01 PM
Trouble with factory method - unhandled exception type Exception desmond5 New To Java 1 03-08-2008 07:41 PM
JSP Exception Hanling Java Tip Java Tips 0 12-24-2007 10:57 AM
Exception Camden New To Java 2 11-27-2007 12:50 AM


All times are GMT +2. The time now is 11:27 PM.



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