You read the data from inputStream not from outputStream.
OutputStream is used to pass data to the process.
There are two basic input streams for Process
. One is for standard input and can be retrieved with getInputStream()
the other is for errors and can be retrieved with getErrorStream()
From javadoc of getInputStream()
:
Returns the input stream connected to the normal output of the
subprocess
and from getErrorStream()
Returns the input stream connected to the error output of the
subprocess.
Note on streams: from the java program perspective a Process
is an external program. When you need to add some input to the external program you write from java to that program (so the output of java program is the input of Process). Instead if the external program writes something you read it (so the output of Process is the input for the java program).
Java Data direction External Process
_____________________________________________________________
write to OutputStream ------------> read from InputStream
read from InputStream <------------ write to OutputStream
Process
"wrapping" Consul would make STDOUT available via anOutputStream
(it's a stream of chars sent from Consul out to STDOUT). This is correct, and when I can give you the green check in a few mins I will do so, but to the Java Gods I say this: curse you, oh Java Gods, you've got it backwards!!! – Break