在 java 8 中,我使用 Process 和 ProcessBuilder 启动一个进程来运行 python 文件
当进程运行时,它要求我输入。
我在 ProcessBuilder 中看到有一个方法 redirectInput,我试过了,效果很好。但问题是输入不能是静态的。它总是根据 python 处理的值而变化。
有没有办法在不使用redirectInput的情况下向正在运行的进程发送输入?
在java中
//create process builder and process to run python code
ProcessBuilder pb = new ProcessBuilder(PYTHON, CODE_FOR_RECORD_LINKAGE)
.redirectInput(new File(INPUT_RECORD_LINKAGE))
.redirectOutput(new File(OUTPUT_RECORD_LINKAGE))
.redirectError(new File(ERROR_RECORD_LINKAGE));
Process p = pb.start();
在命令行中
0/10 positive, 0/10 negative
Do these records refer to the same thing?
(y)es / (n)o / (u)nsure / (f)inished