I'm reading an older version of Java book that was doing some HTML processing.
It uses this while loop conditional statement:
(line = r.readLine()) != null.
r is a BufferedReader variable constructed from new BufferedReader(new InputStreamReader(System.in))
In Eclipse console, I'm not sure how to input null to break out of this while loop. (Control C doesn't work)
I find that if I use empty string test of !(line = r.readLine()).isEmpty() or !(line = r.readLine()).equals("") will break out of the while loop if I press Enter twice.
But this uses an empty string, not a null.
Although this seems to be more intuitive, but the HTML script can contain empty line as well, so I won't be able to process HTML scripts that have empty lines if it terminate on empty string.
How can we input null from the console?
Is the program intended to read from a file instead? What's the best way to input and set termination for this?
Update:
As seen from a related question, this problem with Eclipse IDE can be solved via "Control + Z". It inputs "null".