public class ConsoleConsumer extends Object implements Runnable
InputStream
and write it to an OutputStream
. This is
commonly used when a processes stdout
or stderr
needs to be consumed and redirected somewhere.Constructor and Description |
---|
ConsoleConsumer(InputStream in,
OutputStream out)
Creates a new console consumer which will pipe the
InputStream to the OutputStream . |
Modifier and Type | Method and Description |
---|---|
void |
run() |
static Thread |
start(InputStream in,
OutputStream out)
Creates and starts a daemon thread which pipes int
InputStream to the OutputStream . |
static Thread |
start(Process process,
OutputStream out)
|
public ConsoleConsumer(InputStream in, OutputStream out)
InputStream
to the OutputStream
.in
- the input stream that should be pippedout
- the output stream where the data should be writtenpublic static Thread start(Process process, OutputStream out)
stdout
stream and pipes the date to the output stream.
Note that when using this method the ProcessBuilder.redirectErrorStream(boolean)
should likely be
true
. Otherwise another thread should be created to
consume stderr
.
process
- the processout
- the output stream where the data should be writtenpublic static Thread start(InputStream in, OutputStream out)
InputStream
to the OutputStream
.in
- the input stream that should be pippedout
- the output stream where the data should be writtenCopyright © 2021 JBoss by Red Hat. All rights reserved.