In jline2 (jline-2.1.2.jar), the ConsoleReader discards the line content which has been read and returns null when the line reaches the end of the stream. See snippet of code in
class jline.console.ConsoleReader.java method:
public String readLine(String prompt, final Character mask) throws IOException:
int c = pushBackChar.isEmpty() ? readCharacter() : pushBackChar.pop ();
if (c == -1) {
return null;
}
and readCharacter():
public final int readCharacter() throws IOException {
int c = reader.read();
if (c >= 0) {
Log.trace("Keystroke: ", c);
// clear any echo characters
if (terminal.isSupported()) {
clearEcho(c);
}
}
return c;
}
When EOF is reached in this line, the getCharacter() returns -1 and readLine returns null.