• Post Reply Bookmark Topic Watch Topic
  • New Topic

errors i just don't understand  RSS feed

 
Nick Allen
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this bit of code is giving me a 'must be caught or declared to be thrown error":

it highlights the last line for the error. i'm sure i'm just missing something, but what?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The method BufferedReader.readLine() is declared to throw IOException. This means that for any code that calls this method, one of the following must be true: there must either be a try/catch block which handles this exception, or the method in which the call to readLine() appears must itself declare that it throws IOException or a superclass of IOException. So, for example:
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!