I\'m a beginner java programmer following the java tutorials.
I am using a simple Java Program from the Java tutorials\'s Data Streams Page, and at runtime, it keeps
You catch IOException
which also catches EOFException
, because it is inherited. If you look at the example from the tutorial they underlined that you should catch EOFException
- and this is what they do. To solve you problem catch EOFException
before IOException
:
try
{
//...
}
catch(EOFException e) {
//eof - no error in this case
}
catch(IOException e) {
//something went wrong
e.printStackTrace();
}
Beside that I don't like data flow control using exceptions - it is not the intended use of exceptions and thus (in my opinion) really bad style.