File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Exception question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Exception question" Watch "Exception question" New topic

Exception question

Dinesh Tahiliani
Ranch Hand

Joined: Aug 06, 2007
Posts: 486

output :Exception in thread "main" java.lang.Error: Unresolved compilation problem:
Unhandled exception type IOException

at testkg.ParentUltil.main(

Can anyone please explain me this output.
I think we are catching the IOexception but then why its giving error

Thanks<br />Dinesh
Alexey Saenko
Ranch Hand

Joined: Aug 18, 2008
Posts: 30

Hi Dinesh,
please take a look at full signature of FileOutputStream.close(), here it is:

So, you should surround it with one more try/catch block

My blog:
Brian Legg
Ranch Hand

Joined: Nov 07, 2008
Posts: 488
Dinesh, I usually wrap all file i/o in its own try/catch like this:

I just hacked it together, so I appologize for any errors.

EDIT: First time using code blocks, lol
[ November 19, 2008: Message edited by: Brian Legg ]

~Currently preparing for SCJP6
I agree. Here's the link:
subject: Exception question
It's not a secret anymore!