Class IOUtil
java.lang.Object
org.fife.rsta.ac.IOUtil
I/O related utility methods. We should think of a better location for
these methods.
- Version:
- 1.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the environment of the current process.static String[]getEnvironmentSafely(String[] toAdd) Returns the environment of the current process, with some variables possibly added/overwritten.static StringgetEnvSafely(String var) Returns the value of an environment variable.static voidUtility testing method.static intwaitForProcess(Process p, StringBuilder stdout, StringBuilder stderr) Runs a process, possibly capturing its stdout and/or stderr.
-
Field Details
-
defaultEnv
-
-
Constructor Details
-
IOUtil
private IOUtil()Private constructor to prevent instantiation.
-
-
Method Details
-
getDefaultEnvMap
-
getEnvSafely
Returns the value of an environment variable. This method is here so we don't get an exception when calling System.getenv() in Java 1.4 (which we support).- Parameters:
var- The environment variable.- Returns:
- The value of the variable, or
nullif it is not defined.
-
getEnvironmentSafely
Returns the environment of the current process, with some variables possibly added/overwritten. This method works even with Java 1.4.- Parameters:
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.- Returns:
- The environment variables. This array's entries will be of the
form "
name=value", so it can be passed directly intoRuntime.exec().
-
waitForProcess
public static int waitForProcess(Process p, StringBuilder stdout, StringBuilder stderr) throws IOException Runs a process, possibly capturing its stdout and/or stderr.- Parameters:
p- The process.stdout- A buffer in which to put stdout, ornullif you don't want to keep it.stderr- A buffer in which to keep stderr, ornullif you don't want to keep it.- Returns:
- The return code of the process.
- Throws:
IOException- If an IO error occurs.
-
main
Utility testing method.- Parameters:
args- Command line arguments.
-