dk.netarkivet.common.utils
Class ProcessUtils

java.lang.Object
  extended by dk.netarkivet.common.utils.ProcessUtils

public class ProcessUtils
extends java.lang.Object

Various utilities for running processes -- not exactly Java's forte.


Constructor Summary
ProcessUtils()
           
 
Method Summary
static void discardProcessOutput(java.io.InputStream inputStream)
          Read the output from a process.
static int runProcess(java.lang.String... programAndArgs)
          Runs an external process that takes no input, discarding its output.
static int runProcess(java.lang.String[] environment, java.lang.String... programAndArgs)
          Runs an external process that takes no input, discarding its output.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProcessUtils

public ProcessUtils()
Method Detail

runProcess

public static int runProcess(java.lang.String[] environment,
                             java.lang.String... programAndArgs)
Runs an external process that takes no input, discarding its output.

Parameters:
environment - An environment to run the process in (may be null)
programAndArgs - The program and its arguments.
Returns:
The return code of the process.

runProcess

public static int runProcess(java.lang.String... programAndArgs)
Runs an external process that takes no input, discarding its output. This is a convenience wrapper for runProcess(environment, programAndArgs)

Parameters:
programAndArgs - The program to run and its arguments
Returns:
The return code of the process.

discardProcessOutput

public static void discardProcessOutput(java.io.InputStream inputStream)
Read the output from a process. Due to oddities in the Process handling, this has to be done char by char. This method just implements a consumer thread to eat the output of a process and so prevent blocking.

Parameters:
inputStream - A stream to read up to end of file. This stream is closed at