Results 1 to 2 of 2
Thread: throws Exception
- 11-06-2007, 07:09 PM #1
Member
- Join Date
- Nov 2007
- Posts
- 97
- Rep Power
- 0
throws Exception
Hi,
While declaring objects of some classes, like FileInputStream, FileOutputStream, ObjectInputStream etc, we need to declare them in a try catch block. Otherwise we get exception saying Unhandled exception. One other way is to use throws exception with the method name in which we are declaring the object. For example:
Which is the right way?Java Code:public void myFunction() throws Exception{ FileInputStream f_in = new FileInputStream("C:\\myvector.data"); ... }
Thanks in advance.
- 11-06-2007, 07:32 PM #2
Similar Threads
-
Where does the exception go?
By aytidaalkuhs in forum New To JavaReplies: 3Last Post: 04-07-2008, 02:24 PM -
Xml Parse throws SaxParseException. Encoding is UTF-8 insteadof ISO-8859-1 ?
By j_kathiresan in forum XMLReplies: 1Last Post: 03-28-2008, 05:08 PM -
Trouble with factory method - unhandled exception type Exception
By desmond5 in forum New To JavaReplies: 1Last Post: 03-08-2008, 06:41 PM -
Difference between Throws and Throw
By Poonam in forum New To JavaReplies: 7Last Post: 02-06-2008, 04:52 PM -
Main method with throws Exception
By bugger in forum New To JavaReplies: 3Last Post: 01-07-2008, 02:48 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks