Package org.wildfly.plugin.tools
Class ConsoleConsumer
java.lang.Object
org.wildfly.plugin.tools.ConsoleConsumer
- All Implemented Interfaces:
Runnable
A utility which will consume output from an
InputStream
and write it to an OutputStream
. This is
commonly used when a processes stdout
or stderr
needs to be consumed and redirected somewhere.- Author:
- James R. Perkins
-
Constructor Summary
ConstructorsConstructorDescriptionConsoleConsumer
(InputStream in, OutputStream out) Creates a new console consumer which will pipe theInputStream
to theOutputStream
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
run()
static Thread
start
(InputStream in, OutputStream out) Creates and starts a daemon thread which pipes intInputStream
to theOutputStream
.static Thread
start
(Process process, OutputStream out)
-
Constructor Details
-
ConsoleConsumer
Creates a new console consumer which will pipe theInputStream
to theOutputStream
.- Parameters:
in
- the input stream that should be pippedout
- the output stream where the data should be written
-
-
Method Details
-
start
Creates and starts a daemon thread which consumes a processesstdout
stream and pipes the date to the output stream.Note that when using this method the
ProcessBuilder.redirectErrorStream(boolean)
should likely betrue
. Otherwise another thread should be created to consumestderr
.- Parameters:
process
- the processout
- the output stream where the data should be written- Returns:
- the thread that was started
-
start
Creates and starts a daemon thread which pipes intInputStream
to theOutputStream
.- Parameters:
in
- the input stream that should be pippedout
- the output stream where the data should be written- Returns:
- the thread that was started
-
run
public void run()
-