Java reading standard output from an external program using inputstream

前端 未结 5 1960
自闭症患者
自闭症患者 2020-12-10 20:19

I am trying to develop a class that reads the standard output of an external program(using an instance of Process, Runtime.getRuntime().exec(cmdLine, env, dir)). The program

5条回答
  •  佛祖请我去吃肉
    2020-12-10 20:50

    For one thing, this may block if it's writing to the error stream and has exhausted the buffer - you're not reading from the error stream until the output stream has completely finished.

    Next, you say it takes user input during the process - are you giving it any user input by writing to stdin? If it's waiting for input, you should write to stdin appropriately, and flush it.

提交回复
热议问题