[java] Catch end of file on stdin

java.io.NativeInput must expect -1 and not an EOFException