你需要使用
ProcessBuilder重定向。
ProcessBuilder builder = new ProcessBuilder("sh", "somescript.sh");builder.redirectOutput(new File("out.txt"));builder.redirectError(new File("out.txt"));Process p = builder.start(); // may throw IOException
你需要使用
ProcessBuilder重定向。
ProcessBuilder builder = new ProcessBuilder("sh", "somescript.sh");builder.redirectOutput(new File("out.txt"));builder.redirectError(new File("out.txt"));Process p = builder.start(); // may throw IOException