这是我目前的代码:
ProcessBuilder builder = new ProcessBuilder(
"cmd.exe", "/c", cmd1 + " && " + cmd2 + " && " + cmd3 + " && " + cmd4 + " && " + cmd5 + " && " + cmd6
);
builder.directory(new File(workspace.toString()));
builder.redirectErrorStream(true);
Process p = builder.start();
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while(true) {
line = r.readLine();
if(line == null) {
break;
}
//textPanel.appendText(line);
System.err.println(line);
textPanel.appendText(line);
}
如何检查所有命令是否成功执行,cmd6完成后,它会发送一条sysout消息?
我无法弄清楚如何做到这一点......