I got the proper EOF criteria in Java with this question and it is doing fine. But the problem occurred when a program required an input of a blank line after each input case. The following code works fine for EOF.
String line;
BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
try {
while((line = read.readLine()) != null){
n = Integer.parseInt(line);
}
}
catch (IOException e) {}
But the problem is, I got to solve a problem where after input of each case, a blank new line is inputted. As a result I am getting a NumberFormatException and this is expected too. I have tried all that I could do including try-catch() mechanism.
It would be great if I have a code that doesn't terminate or throw exception on a blank line input.