I am trying to interact with another process in Java. It happens like this ...
Runtime rt;
Process pr=rt.exec("cmd");
then I send some commands to the process using ...
BufferedReader processOutput = new BufferedReader(new InputStreamReader(pr.getInputStream()));
BufferedWriter processInput = new BufferedWriter(new OutputStreamWriter(pr.getOutputStream()));
processInput.write("gdb");
processInput.flush();
At the moment, I'm not interested in getting out. So I try to ignore it with.
while(processOutput.readLine() != null);
but this loop is forever. I know this because the process is still running and is not sending zero. I do not want to stop it now. I need to send commands based on user input and then get output.
How to do it? In other words, I want to reset the Process output or ignore it after executing some commands and read it only when I want.
user963395
source
share