In my Java program, I call an .exe program using this code:
Process process = new ProcessBuilder("C:\\PathToExe\\MyExe.exe").start();
I pass parameters to it. How do I retrieve the output from the .exe so I can store it in a String[]?
1 Answer
You can retrieve any input and/or output of your program by using:
- java.lang.Process.getErrorStream() to retrieve the error output (stderr)
- java.lang.Process.getInputStream() to retrieve the input stream you can write to (stdin)
- java.lang.Process.getOutputStream() to retrieve the output stream (the regular output of the program) (stdout)