org.marketcetera.util.exec
Class Exec

java.lang.Object
  extended by org.marketcetera.util.exec.Exec

public final class Exec
extends Object

A simple process executor. The executed process requires no input, and the interleaved mix of its standard output and error streams is directed to either the JVM's standard output or error stream, or to an in-memory array.

Since:
0.5.0
Version:
$Id: Exec.java 16154 2012-07-14 16:34:05Z colin $
Author:
tlerios@marketcetera.com

Constructor Summary
Exec()
           
 
Method Summary
static ExecResult run(File directory, Disposition disposition, String... args)
          Executes the process with the given arguments and returns the execution result.
static ExecResult run(String name, Disposition disposition, String... args)
          Executes the process with the given arguments and returns the execution result.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Exec

public Exec()
Method Detail

run

public static ExecResult run(File directory,
                             Disposition disposition,
                             String... args)
                      throws I18NException
Executes the process with the given arguments and returns the execution result. The first argument must be the required executable/binary command. The working directory of the process is set to the given one. The interleaved output and error streams of the process are redirected/captured as per the given setting.

Parameters:
directory - The working directory. Use null for the JVM's current working directory.
disposition - The disposition of the output.
args - The process arguments.
Returns:
The execution result.
Throws:
I18NInterruptedException - Thrown if process execution fails due to an interruption.
I18NException - Thrown if process execution fails for any other reason.

run

public static ExecResult run(String name,
                             Disposition disposition,
                             String... args)
                      throws I18NException
Executes the process with the given arguments and returns the execution result. The first argument must be the required executable/binary command. The name of the working directory of the process is set to the given one. The interleaved output and error streams of the process are redirected/captured as per the given setting.

Parameters:
name - The name of the working directory. Use null for the JVM's current working directory.
disposition - The disposition of the output.
args - The process arguments.
Returns:
The execution result.
Throws:
I18NException - Thrown if process execution fails.


Copyright © 2012. All Rights Reserved.