The behavior is the same as on MacOS: If Ctrl-D is pressed with
an empty input string (i.e. nothing else has been entered), then
the stream is closed and read() will return -1. If other
characters have already been entered, then those characters
will be used as input, the stream is NOT closed, but contrary
to pressing Enter, no newline character is entered.
Implements feature request: 1470491
Allow "end of file" in System.in input
https://sourceforge.net/tracker2/?func=detail&aid=1470491&group_id=44253&atid=438938