• Post Reply Bookmark Topic Watch Topic
  • New Topic

exception EmptyFileException is never thrown in body of corresponding try statement  RSS feed

 
Kd Martin
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello. I am writing a program to read data from a file and use that data to create a university object. I had to create the class EmptyFileException. This exception is thrown when a file is empty. When I try to compile I get this error:

University.java:213: exception EmptyFileException is never thrown in body of corresponding try statement
} catch (EmptyFileException e) {
^


Could someone help me understand how to fix this? Thank you!




 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message is telling you exactly what's wrong. There's nothing in that try block than can throw that exception. The compiler doesn't allow you to catch an exception that it knows cannot occur.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!