public class IOUtil
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String[] |
getEnvironmentSafely(java.lang.String[] toAdd)
Returns the environment of the current process, with some variables
possibly added/overwritten.
|
static java.lang.String |
getEnvSafely(java.lang.String var)
Returns the value of an environment variable.
|
static void |
main(java.lang.String[] args)
Utility testing method.
|
static int |
waitForProcess(java.lang.Process p,
java.lang.StringBuffer stdout,
java.lang.StringBuffer stderr)
Runs a process, possibly capturing its stdout and/or stderr.
|
public static java.lang.String getEnvSafely(java.lang.String var)
var - The environment variable.null if it is not
defined.public static java.lang.String[] getEnvironmentSafely(java.lang.String[] toAdd)
toAdd - The environment variables to add/overwrite in the returned
array. This array should have an even length, with even indices
containing variable names and odd indices containing the variable
values.name=value", so it can be passed directly
into Runtime.exec().public static int waitForProcess(java.lang.Process p,
java.lang.StringBuffer stdout,
java.lang.StringBuffer stderr)
throws java.io.IOException
p - The process.stdout - A buffer in which to put stdout, or null if
you don't want to keep it.stderr - A buffer in which to keep stderr, or null
if you don't want to keep it.java.io.IOException - If an IO error occurs.public static void main(java.lang.String[] args)
args - Command line arguments.