I'm reading from standard input using the following loop:
Scanner stdin = new Scanner(System.in);
while (stdin.hasNextLine() && stdin.nextLine() != null) {
String line = stdin.nextLine();
if (!(line.contains("#"))) {
input.add(line);
}
if (line.contentEquals("q")) {
break;
}
}
Now this is easy to terminate if I simply type q
and press enter, however I'm supposed to terminate the program when the user presses Ctrl + d
on a new line. I can't get this to work, when I press Ctrl + d
nothing happens.