1

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[]?

0

1 Answer 1

1

You can retrieve any input and/or output of your program by using:

  1. java.lang.Process.getErrorStream() to retrieve the error output (stderr)
  2. java.lang.Process.getInputStream() to retrieve the input stream you can write to (stdin)
  3. java.lang.Process.getOutputStream() to retrieve the output stream (the regular output of the program) (stdout)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.