Example usage for org.apache.commons.exec DefaultExecutor DefaultExecutor

List of usage examples for org.apache.commons.exec DefaultExecutor DefaultExecutor

Introduction

In this page you can find the example usage for org.apache.commons.exec DefaultExecutor DefaultExecutor.

Prototype

public DefaultExecutor() 

Source Link

Document

Default constructor creating a default PumpStreamHandler and sets the working directory of the subprocess to the current working directory.

Usage

From source file:wf.frk.tilde.sblauncher.SauerbratenExecutor.java

public void startThread(String executable, String[] params, String working_dir)
        throws ExecuteException, IOException {

    setDaemon(true);//from   ww w.  j ava  2  s  .c o m
    startThread();

    CommandLine cmdLine = CommandLine.parse(executable);
    for (String p : params) {
        System.out.println(p);

        cmdLine.addArgument(p);
    }

    DefaultExecutor executor = new DefaultExecutor();

    PipedOutputStream output = new PipedOutputStream();
    PumpStreamHandler streamHandler = new PumpStreamHandler(output, System.err);
    SAUER_OUTPUT = new Scanner(new PipedInputStream(output));

    executor.setStreamHandler(streamHandler);
    executor.setWorkingDirectory(new File(working_dir));
    executor.execute(cmdLine);

}