org.fife.rsta.ac
Class IOUtil

java.lang.Object
  extended by org.fife.rsta.ac.IOUtil

public class IOUtil
extends Object

I/O related utility methods. We should think of a better location for these methods.

Version:
1.0
Author:
Robert Futrell

Method Summary
static String[] getEnvironmentSafely(String[] toAdd)
          Returns the environment of the current process, with some variables possibly added/overwritten.
static String getEnvSafely(String var)
          Returns the value of an environment variable.
static void main(String[] args)
          Utility testing method.
static int waitForProcess(Process p, StringBuffer stdout, StringBuffer stderr)
          Runs a process, possibly capturing its stdout and/or stderr.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEnvSafely

public static String getEnvSafely(String var)
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 null if it is not defined.

getEnvironmentSafely

public static String[] getEnvironmentSafely(String[] toAdd)
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 into Runtime.exec().

waitForProcess

public static int waitForProcess(Process p,
                                 StringBuffer stdout,
                                 StringBuffer 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, 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.
Returns:
The return code of the process.
Throws:
IOException - If an IO error occurs.

main

public static void main(String[] args)
Utility testing method.

Parameters:
args - Command line arguments.


Copyright © 2003-2011. All Rights Reserved.