public abstract class CommandLineUtils
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
CommandLineUtils.StringStreamConsumer |
Constructor and Description |
---|
CommandLineUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
executeCommandLine(Commandline cl,
java.io.InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr) |
static int |
executeCommandLine(Commandline cl,
java.io.InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
int timeoutInSeconds) |
static int |
executeCommandLine(Commandline cl,
java.io.InputStream systemIn,
StreamConsumer systemOut,
StreamConsumer systemErr,
int timeoutInSeconds,
java.lang.Runnable runAfterProcessTermination) |
static int |
executeCommandLine(Commandline cl,
StreamConsumer systemOut,
StreamConsumer systemErr) |
static int |
executeCommandLine(Commandline cl,
StreamConsumer systemOut,
StreamConsumer systemErr,
int timeoutInSeconds) |
static java.util.Properties |
getSystemEnvVars()
Gets the shell environment variables for this process.
|
static java.util.Properties |
getSystemEnvVars(boolean caseSensitive)
Return the shell environment variables.
|
static java.lang.String |
toString(java.lang.String... line) |
static java.lang.String[] |
translateCommandline(java.lang.String toProcess) |
public static int executeCommandLine(Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr) throws CommandLineException
CommandLineException
public static int executeCommandLine(Commandline cl, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds) throws CommandLineException
CommandLineException
public static int executeCommandLine(Commandline cl, java.io.InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr) throws CommandLineException
CommandLineException
public static int executeCommandLine(Commandline cl, java.io.InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds) throws CommandLineException
cl
- The command line to executesystemIn
- The input to read from, must be thread safesystemOut
- A consumer that receives output, must be thread safesystemErr
- A consumer that receives system error stream output, must be thread safetimeoutInSeconds
- Positive integer to specify timeout, zero and negative integers for no timeout.Process.exitValue()
CommandLineException
- or CommandLineTimeOutException if time out occurspublic static int executeCommandLine(Commandline cl, java.io.InputStream systemIn, StreamConsumer systemOut, StreamConsumer systemErr, int timeoutInSeconds, java.lang.Runnable runAfterProcessTermination) throws CommandLineException
cl
- The command line to executesystemIn
- The input to read from, must be thread safesystemOut
- A consumer that receives output, must be thread safesystemErr
- A consumer that receives system error stream output, must be thread safetimeoutInSeconds
- Positive integer to specify timeout, zero and negative integers for no timeout.runAfterProcessTermination
- Optional callback to run after the process terminated or the the timeout was
exceeded, but before waiting on the stream feeder and pumpers to finish.Process.exitValue()
CommandLineException
- or CommandLineTimeOutException if time out occurspublic static java.util.Properties getSystemEnvVars()
getSystemEnvVars().get("path")
and getSystemEnvVars().get("PATH")
will in general return different values. However, on platforms
with case-insensitive environment variables like Windows, all variable names will be normalized to upper case.null
.System.getenv() API, new in JDK 5.0, to get the same result
since 2.0.2 System#getenv() will be used if available in the current running jvm.
public static java.util.Properties getSystemEnvVars(boolean caseSensitive)
caseSensitive == true
, then envar
keys will all be upper-case.caseSensitive
- Whether environment variable keys should be treated case-sensitively.System.getenv() API, new in JDK 5.0, to get the same result
since 2.0.2 System#getenv() will be used if available in the current running jvm.
public static java.lang.String[] translateCommandline(java.lang.String toProcess) throws java.lang.Exception
java.lang.Exception
public static java.lang.String toString(java.lang.String... line)
Copyright © 2013. All Rights Reserved.