When running a process, how do I pipe it's output to System.out
and it's input to System.in
:
Process p = Runtime.getRuntime().exec("cubc.exe");
// do something with p.getOutputStream())
EDIT: I think I explained this wrong; I don't want to input to the program, I want the user to input to the program, and I don't want to read the output, I want the user to read the output.
Using IOUtils
class from Apache Commons IO:
Process p = Runtime.getRuntime().exec("cubc.exe");
IOUtils.copy(p.getInputStream(), System.out);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With