Alex Rivera | Logout

Java Process getInputStream vs. getOutputStream

Asked 2010-11-19T19:55:56.030
15

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?

Edit
Report

1 Answer

9

I always ignore the names and look at what's returned. If your code has an OutputStream, you can write to it - which means it's the input for the other process. If your code has an InputStream, you can read from it - which means it's the output or error for the other process.

Fortunately, the compiler will tell you if you're doing the wrong thing - you've got the data you want to provde, so you've got to write it to the stream, which means it's got to be the OutputStream.

answered 2010-11-19T19:58:11.173

Your Answer