I’m a bit confused about the streams… which is which?
Simply, which stream should I use to catch the output of my Process, and which stream should I use to give my Process some input?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You can only read from an
InputStream, so use that to catch the output of your process.You write to an
OutputStream, so use that to give the process your input.You are using names that make sense in the context of the spawned process. But the API names make sense in the context of the parent process.
Here’s another tip: if your process writes to standard error, be sure to read that too. If standard output or error pipes of the sub-process are full (because your parent Java process isn’t consuming them), the child process will block on its
write()calls.