Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 为什么Process.waitfor不';你不回来了吗?_Java_Process_Runtime.exec - Fatal编程技术网

Java 为什么Process.waitfor不';你不回来了吗?

Java 为什么Process.waitfor不';你不回来了吗?,java,process,runtime.exec,Java,Process,Runtime.exec,这是我的密码。请复习一下。似乎p.waitFor()没有返回,请帮助我。谢谢 try { String svnCmd="svn diff -r " +startVersion +":" + endVersion +" --summarize --username testdomain\\tesuer --password test.123 http://cvs-server.testserver.com:8001/svn/projects/testproj

这是我的密码。请复习一下。似乎
p.waitFor()
没有返回,请帮助我。谢谢

try
        {
            String svnCmd="svn diff -r " +startVersion +":" + endVersion +" --summarize --username testdomain\\tesuer --password test.123 http://cvs-server.testserver.com:8001/svn/projects/testproject/";

            Process p = Runtime.getRuntime().exec(svnCmd);
            p.waitFor();
            BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line = reader.readLine();
            while (line != null)
            {
                System.out.println(line);
                line = reader.readLine();
            }
        }
        catch (IOException e1)
        {

        }
        catch (InterruptedException e2)
        {

        }

        System.out.println("Done");

我猜,但Process API有一个常见问题,即您必须使用进程的stdout和stderr,否则当支持这些流(操作系统级别)的缓冲区填满时,外部进程可能会阻塞

典型的方法是在后台启动一个或多个线程来使用这些信息


与其自己滚动,我倒不如用它来帮你处理这个问题。

你为什么不在这里发布“回顾”问题->?还有更合适的地方。我认为这篇文章今天仍然很有意义:除了实现@PhiLho链接的文章中的所有建议之外,我建议1)将每个捕获从
catch(IOException e1){}
更改为
catch(IOException e1){e1.printStackTrace();}
2)使用
ProcessBuilder
创建
流程
3)将
字符串
命令分解为
字符串[]