Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception question

 
Dinesh Tahiliani
Ranch Hand
Posts: 486
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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

at testkg.ParentUltil.main(ParentUltil.java:34)

Can anyone please explain me this output.
I think we are catching the IOexception but then why its giving error
 
Alexey Saenko
Ranch Hand
Posts: 30
Chrome Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Brian Legg
Ranch Hand
Posts: 488
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic