Error message “unreported exception java.io.IOException; must be caught or declared to be thrown” [duplicate]

void showfile() throws java.io.IOException  <-----

Your showfile() method throws IOException, so whenever you use it you have to either catch that exception or again thorw it. Something like:

try {
  showfile();
}
catch(IOException e) {
  e.printStackTrace();
}

You should learn about exceptions in Java.

Leave a Comment