Capturing stdout when calling Runtime.exec

后端 未结 8 1149
终归单人心
终归单人心 2020-11-21 23:26

When experiencing networking problems on client machines, I\'d like to be able to run a few command lines and email the results of them to myself.

I\'ve found Runtim

8条回答
  •  有刺的猬
    2020-11-21 23:45

    VerboseProcess utility class from jcabi-log can help you:

    String output = new VerboseProcess(
      new ProcessBuilder("executable with output")
    ).stdout();
    

    The only dependency you need:

    
      com.jcabi
      jcabi-log
      0.7.5
    
    

提交回复
热议问题