更新时间:2023-01-18 17:55:27
不要在Runtime.exec()里使用重定向符,而是用process.getInputStream()
获得日志。例如:
Process process = Runtime.getRuntime().exec("python /tmp/pytest.py");
try (FileOutputStream out = new FileOutputStream("/tmp/pylog.log")) {
Streams.copy(process.getInputStream(), out);
}