R
Ross
How do you send messages to a child process from inside Java?
I'm running a process by first getting a Runtime from
Runtime.getRuntime();
I then exec a process using Runtime.exec( String [] );
I then get the OutputStream to send info to the process using
Process.getOutputStream();
I then send lines of text to the OutputStream by sending blocks of
bytes. These strings are terminated with newlines.
At the other end (c++ program), I'm using cin to read from standard
output.
But, it seems, whatever I do, the data doesn't get through to the c++
program unless I close the outputstream. Which means that I have to
spark a new process for each command. Which doesn't work. I need to be
sending a continual stream of realtime commands to the c++ program.
How do I do this? Surely there is a way?
I'm running a process by first getting a Runtime from
Runtime.getRuntime();
I then exec a process using Runtime.exec( String [] );
I then get the OutputStream to send info to the process using
Process.getOutputStream();
I then send lines of text to the OutputStream by sending blocks of
bytes. These strings are terminated with newlines.
At the other end (c++ program), I'm using cin to read from standard
output.
But, it seems, whatever I do, the data doesn't get through to the c++
program unless I close the outputstream. Which means that I have to
spark a new process for each command. Which doesn't work. I need to be
sending a continual stream of realtime commands to the c++ program.
How do I do this? Surely there is a way?