Function that will be called with the OutputStream
to
which all input to the process must be written. This will
be called in a newly spawned thread.
Function that will be called with the InputStream
from which all normal output of the process must be
read from. This will be called in a newly spawned
thread.
Function that will be called with the InputStream
from
which all error output of the process must be read from.
This will be called in a newly spawned thread.
Indicates whether the newly spawned threads that
will run processOutput
, processError
and
writeInput
should be marked as daemon threads.
Indicates whether the newly spawned threads that
will run processOutput
, processError
and
writeInput
should be marked as daemon threads.
Creates a new ProcessIO
, with daemonizeThreads
true.
Function that will be called with the InputStream
from
which all error output of the process must be read from.
Function that will be called with the InputStream
from
which all error output of the process must be read from.
This will be called in a newly spawned thread.
Function that will be called with the InputStream
from which all normal output of the process must be
read from.
Function that will be called with the InputStream
from which all normal output of the process must be
read from. This will be called in a newly spawned
thread.
Creates a new ProcessIO
with a different handler for the error output.
Creates a new ProcessIO
with a different handler for the process input.
Creates a new ProcessIO
with a different handler for the normal output.
Function that will be called with the OutputStream
to
which all input to the process must be written.
Function that will be called with the OutputStream
to
which all input to the process must be written. This will
be called in a newly spawned thread.
This class is used to control the I/O of every Process. The functions used to create it will be called with the process streams once it has been started. It might not be necessary to use
ProcessIO
directly -- ProcessBuilder can return the process output to the caller, or use a ProcessLogger which avoids direct interaction with a stream. One can even use the factories atBasicIO
to create aProcessIO
, or use its helper methods when creating one's ownProcessIO
.When creating a
ProcessIO
, it is important to close all streams when finished, since the JVM might use system resources to capture the process input and output, and will not release them unless the streams are explicitly closed.ProcessBuilder
will callwriteInput
,processOutput
andprocessError
in separate threads, and if daemonizeThreads is true, they will all be marked as daemon threads.Failure to close the passed streams may result in resource leakage.