How do I Pipe process output to a file on Windows and JDK 6u45

后端 未结 3 1606
悲&欢浪女
悲&欢浪女 2021-01-17 19:00

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 ba

3条回答
  •  一个人的身影
    2021-01-17 19:37

    This is the simplest method i found on http://tamanmohamed.blogspot.in/2012/06/jdk7-processbuilder-and-how-redirecting.html

    File output = new File("C:/PBExample/ProcessLog.txt");
    ProcessBuilder pb = new ProcessBuilder("cmd");
    pb.redirectOutput(output);
    

提交回复
热议问题