我是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。当我通过命令提示符运行它运行正常。