工作這裏它只是打開一個命令提示符窗口7,然後坐在我的代碼。沒有其他的。我希望它明顯地發送和接收命令。所以最新錯誤?的java管/進程生成不CMD.EXE
String line;
try {
Process p = Runtime.getRuntime().exec("cmd /c start cmd.exe");
BufferedReader inp =
new BufferedReader(
new InputStreamReader(p.getInputStream()));
BufferedWriter out =
new BufferedWriter(
new OutputStreamWriter(p.getOutputStream()));
out.append("sometext");
out.write("Some Text!\n\n");
out.flush();
line = inp.readLine();
System.out.println("response1: " + line); // that's ok
out.write("Second Line...\n");
out.flush();
line = inp.readLine();
// returns an empty string, if it returns...
System.out.println("response2: " + line);
inp.close();
out.close();
} catch (IOException io) {
}
請參閱編輯回答。 –