Results 1 to 4 of 4
Thread: Where does the exception go?
- 04-06-2008, 06:55 PM #1
Member
- Join Date
- Apr 2008
- Posts
- 3
- Rep Power
- 0
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.
Java 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
-
You are just throwing it. That means nobody handles it.
If you write the code like this. You can handle it yourself:
Java 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(); } } }
- 04-07-2008, 10:56 AM #3
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! :cool:
- 04-07-2008, 02:24 PM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
Similar Threads
-
Need help on Exception
By Deon in forum New To JavaReplies: 7Last Post: 02-11-2010, 05:46 PM -
exception
By Oktam in forum New To JavaReplies: 2Last Post: 03-23-2008, 07:01 PM -
Trouble with factory method - unhandled exception type Exception
By desmond5 in forum New To JavaReplies: 1Last Post: 03-08-2008, 06:41 PM -
JSP Exception Hanling
By Java Tip in forum Java TipReplies: 0Last Post: 12-24-2007, 09:57 AM -
Exception
By Camden in forum New To JavaReplies: 2Last Post: 11-26-2007, 11:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks