Capturing stdout when calling Runtime.exec

后端 未结 8 1183
终归单人心
终归单人心 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:37

    Using Runtime.exec gives you a process. You can these use getInputStream to get the stdout of this process, and put this input stream into a String, through a StringBuffer for example.

提交回复
热议问题