ProcessBuilder redirected to standard output

前端 未结 2 1075
Happy的楠姐
Happy的楠姐 2021-02-18 14:56

I would like to redirect a java process output towards the standard output of the parent java process.

Using the ProcessBuilder class as follows:

public          


        
2条回答
  •  广开言路
    2021-02-18 15:49

    Try ProcessBuilder.inheritIO() to use the same I/O as the current Java process. Plus you can daisy chain the methods:

    ProcessBuilder pb = new ProcessBuilder("cmd")
        .inheritIO()
        .directory(new File("C:"));
    pb.start();
    

提交回复
热议问题