This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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
jQuery in Action, 3rd edition