Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception java.io.IOException is never thrown in body of corresponding try statement

 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting an error "exception java.io.IOException is never thrown in body of corresponding try statement" on line #16.

What is wrong with my code? Any insights appreciated. Thank you.


 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the Javadocs for the File class. What exceptions can the constructor and mkdir throw?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's saying that catching an IOException is unnecessary because none of the code in the try block ever throws an IOException. In other words you don't need to surround lines 14 and 15 in a try/catch.
 
Bud Tippins
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks guys. Based on your comments I got it fixed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic