关于Runtime.getRuntime().exec()解决方法

关于Runtime.getRuntime().exec()
现在有这样的一个需求

1、先通过Runtime.getRuntime().exec()执行一段 vb脚本

2、然后脚本执行完之后弹出一个提示窗口。


但现在有个问题,
Runtime.getRuntime().exec()执行一段 vb脚本的时候,他不管你执行没执行完直接就弹出窗口了。


请问有什么能监测到脚本执行进度的方法呢?

------解决方案--------------------
如果你的脚本有输出,试试这个,如果没有,那就不知道了...........
Java code

int c;
String cmd = "....";
Process child = Runtime.getRuntime().exec(cmd);
// 获得运行的输出
InputStream child_in = child.getInputStream();
String strReturn = "";

while ((c = child_in.read()) != -1) {
    strReturn += (char) c;
}
child_in.close(); //得到运行的返回结果

------解决方案--------------------
你要用waitFor等待你的vb脚本执行结束以后再谈出窗口
for example
Java code
Process p = Runtime.getRuntime().exec("vb脚本");
p.waitFor();
JOptionPane.showMessageDialog(null, "finish");

------解决方案--------------------
你不光拿inputstream, errorStream也要拿哦, 不然你程序有死锁情况的