TUM CCSM Commons

edu.tum.cs.commons.io
Class ProcessUtils

java.lang.Object
  extended by edu.tum.cs.commons.io.ProcessUtils

public class ProcessUtils
extends java.lang.Object

Executes a system process. Takes care of reading stdout and stderr of the process in separate threads to avoid blocking.

Version:
$Rev: 26268 $
Author:
juergens, $Author: juergens $
Rating:
GREEN Hash: 4D8721B16BD1F29DDCC9C144FC6E0BCC

Nested Class Summary
static class ProcessUtils.ExecutionResult
          Parameter object that encapsulates the result of a process execution.
 
Constructor Summary
ProcessUtils()
           
 
Method Summary
static ProcessUtils.ExecutionResult execute(java.lang.ProcessBuilder builder)
          Executes a process in a thread-safe way.
static ProcessUtils.ExecutionResult execute(java.lang.ProcessBuilder builder, java.lang.String input)
          Executes a process in a thread-safe way.
static ProcessUtils.ExecutionResult execute(java.lang.String[] completeArguments)
          Executes a process in a thread-safe way.
static ProcessUtils.ExecutionResult execute(java.lang.String[] completeArguments, java.lang.String input)
          Executes a process in a thread-safe way.
 
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

execute

public static ProcessUtils.ExecutionResult execute(java.lang.String[] completeArguments)
                                            throws java.io.IOException
Executes a process in a thread-safe way.

Parameters:
completeArguments - Array of command line arguments to start the process
Returns:
result of the execution
Throws:
java.io.IOException

execute

public static ProcessUtils.ExecutionResult execute(java.lang.String[] completeArguments,
                                                   java.lang.String input)
                                            throws java.io.IOException
Executes a process in a thread-safe way.

Parameters:
completeArguments - Array of command line arguments to start the process
input - String that gets written to stdin
Returns:
result of the execution
Throws:
java.io.IOException

execute

public static ProcessUtils.ExecutionResult execute(java.lang.ProcessBuilder builder)
                                            throws java.io.IOException
Executes a process in a thread-safe way.

Parameters:
builder - builder that gets executed
Returns:
result of the execution
Throws:
java.io.IOException

execute

public static ProcessUtils.ExecutionResult execute(java.lang.ProcessBuilder builder,
                                                   java.lang.String input)
                                            throws java.io.IOException
Executes a process in a thread-safe way.

Parameters:
builder - builder that gets executed
input - String that gets written to stdin
Returns:
result of the execution
Throws:
java.io.IOException

TUM CCSM Commons

TUM CCSM Commons - 2.7