readline () retorna nulo em Java
Estou tentando ler o stdin no meu programa Java. Estou esperando uma série de números seguidos por novas linhas, como:
6
9
1
Ao fornecer a entrada através do console interno do eclipse, tudo corre bem. Mas, ao usar a linha de comando do Windows, o programa imprime:
Received '6'.
Received 'null'.
Invalid input. Terminating. (This line is written by another function that does an Integer.parseint()).
Meu código é:
static String readLineFromStdIn(){
try{
java.io.BufferedReader stdin = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
String input = new String();
input = stdin.readLine();
System.out.println("Received '" + input + "'");
return(input);
}catch (java.io.IOException e) {
System.out.println(e);
}
return "This should not have happened";
}
Alguma pista?