Мой код:Почему моя readLine возвращает null?
String correr = "msg /SERVER:" + NomePC.replace(" ", "") + " * /TIME:300 \"" + Mensagem + "\"";
Process textoo = null;
try {
textoo = Runtime.getRuntime().exec(correr);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
BufferedReader innTexto = new BufferedReader(new InputStreamReader(textoo.getInputStream()));
String lineTexto=null;
try {
lineTexto = innTexto.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if (lineTexto != null) {
System.out.println("Não passou");
}
else if (lineTexto == null) {
System.out.println("A sua mensagem foi enviada com sucesso para " + NomePC + " ás: " + dataFormatada);
}
Так что мой Readline всегда пустой, и я не знаю, почему. Я распечатал его, чтобы подтвердить. Когда я выполнял свою команду в cmd, у меня был ответ. Так почему же он не читает строки?
Im trying with an array of strings. Still not working
Вы уверены, что команда не в настоящее время записи в поток ошибок? –
Да, я. Я пробовал все, что мог. –
Возможный дубликат [Невозможно получить getInputStream из Runtime.getRunTime.exec()] (http://stackoverflow.com/questions/17038324/cannot-get-the-getinputstream-from -runtime-getruntime-exec) –