| Constructor and Description |
|---|
ProcessUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Process |
launchProcess(ProcessBuilder builder,
Optional<ProcessInheritIODisabled> processInheritIODisabled)
|
static Process |
launchProcessStreamStdOut(ProcessBuilder builder,
Optional<ProcessInheritIODisabled> processInheritIODisabled)
|
static void |
streamErrorTo(PrintStream printStream,
Process process)
|
static void |
streamErrorToSysErr(Process process)
|
static void |
streamOutputToSysOut(Process process)
|
static void |
streamToSysOutSysErr(Process process)
This is a convenience method which internally calls both the
streamOutputToSysOut(Process)
and streamErrorToSysErr(Process) methods |
public static Process launchProcess(ProcessBuilder builder, Optional<ProcessInheritIODisabled> processInheritIODisabled) throws IOException
Process built from the builder.
Before launching the process, this method checks if inherit IO is disabled
and if so, streams both the STDOUT and STDERR of the launched process using
streamToSysOutSysErr(Process). Else, it launches the process with ProcessBuilder.inheritIO()builder - The process builderprocessInheritIODisabled - Whether or not ProcessBuilder.Redirect.INHERIT can be used for
launching the processIOExceptionpublic static Process launchProcessStreamStdOut(ProcessBuilder builder, Optional<ProcessInheritIODisabled> processInheritIODisabled) throws IOException
Process built from the builder.
Before launching the process, this method checks if inherit IO is disabled
and if so, streams (only) the STDOUT of the launched process using streamOutputToSysOut(Process)
(Process)}. Else, it launches the process with ProcessBuilder.inheritIO()builder - The process builderprocessInheritIODisabled - Whether or not ProcessBuilder.Redirect.INHERIT can be used for
launching the processIOExceptionpublic static void streamToSysOutSysErr(Process process)
streamOutputToSysOut(Process)
and streamErrorToSysErr(Process) methodsprocess - The process whose STDOUT and STDERR needs to be streamed.public static void streamOutputToSysOut(Process process)
process' STDOUT to the current process'
System.out stream. This creates and starts a thread to stream the contents.
The Process is expected to have been started in ProcessBuilder.Redirect.PIPE
modeprocess - The process whose STDOUT needs to be streamed.public static void streamErrorToSysErr(Process process)
process' STDERR to the current process'
System.err stream. This creates and starts a thread to stream the contents.
The Process is expected to have been started in ProcessBuilder.Redirect.PIPE
modeprocess - The process whose STDERR needs to be streamed.public static void streamErrorTo(PrintStream printStream, Process process)
process' STDERR to the given
printStream. This creates and starts a thread to stream the contents.
The Process is expected to have been started in ProcessBuilder.Redirect.PIPE
modeprocess - The process whose STDERR needs to be streamed.Copyright © 2020 JBoss by Red Hat. All rights reserved.