我在一个单独的命令行控制台中通过exce()函数运行了一个外部工具。
command = "cmd.exe /c start /min doxygen " + strDoxyfilePath;
System.out.println("command : " + command);
//pass the command to execute
Process p=Runtime.getRuntime().exec(command);我将其用于读取输入流:
BufferedReader br = new BufferedReader(new InputStreamReader
(p.getInputStream(), "UTF-8")); //read output of doxygen
String line = null;
while ((line = br.readLine()) != null){
System.out.println("I M HERE: "+line);
}但是控制没有进入while循环,我想在进程结束时得到适当的信号。
发布于 2011-10-28 13:00:01
我想这是因为你的命令中的start。你这样做可能是为了避免cmd窗口,但我认为你不能不与程序交互。
试一试
command = "cmd.exe /c doxygen " + strDoxyfilePath; 另外,请注意
你还需要阅读stderr (p.getErrrorStream())
Runtime.exec,ProcessBuilder是一种更新、更好的方法。发布于 2011-10-28 15:36:03
我认为经典的When Runtime.exec() won't仍然最好地解释了这一点。
https://stackoverflow.com/questions/7925233
复制相似问题