How do I Pipe process output to a file on Windows and JDK 6u45
问题 I have the following windows batch file (run.bat): @echo off echo hello batch file to sysout And the following java code, which runs the batch files and redirects output to a file: public static void main(String[] args) throws IOException { System.out.println("Current java version is: " + System.getProperty("java.version")); ProcessBuilder pb = new ProcessBuilder("cmd.exe", "/c", "run.bat" ,">>", "stdout.txt","2>>", "stderr.txt" ); System.out.println("Command is: " + pb.command()); Process