In Java, send commands to another command-line program

后端 未结 4 2021
终归单人心
终归单人心 2020-12-17 22:24

I am using Java on Windows XP and want to be able to send commands to another program such as telnet. I do not want to simply execute another program. I want to execute it,

4条回答
  •  猫巷女王i
    2020-12-17 23:05

    It's not directly an answer to your question, but...

    Instead of using Runtime.exec() you should use a ProcessBuilder and redirect stderr to stdout (ProcessBuilder.redirectErrorStream(true)). Otherwise your process could block if it writes something to stderr (Windows doesn't like it when the output of a process isn't read).

提交回复
热议问题