从ProcessBuilder执行另一个进程时没有获取输入数据流

时间:2017-10-23 08:17:44

标签: java python processbuilder

我是java新手,我使用processbuilder从java调用Python脚本,并在java中尝试读取python输出。

ProcessBuilder pb = new ProcessBuilder(Arrays.asList("python","PyScript.py",""+path));
Process p = pb.start();
String line;
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = in.readLine()) != null)
{
    System.out.println(line);
    logger.debug("Value of python output is"+line);
    System.out.println("in while loop");
}

readline变为null。当我通过命令提示符运行它运行正常。

0 个答案:

没有答案