I get \"IOException
: Stream Closed\" when I run this program. The text contains many lines of data. Program should read each line, do necessary functio
You should put a function call in the while loop, like:
System.out.println("Hi, I'm a row!");
orSystem.out.println(inputLine);
orin order to let it to execute properly.
The code as it is written executes (comments omitted):
...
while ((inputLine = in.readLine()) != null)
in.close();
...
so the first cycle of the loop executes correctly and runs in.close()
. Then the second cycle the call inputLine = in.readLine()
fails because the stream is closed and then the exception is thrown.