cakoose.util.exec
Class Exec

java.lang.Object
  extended by cakoose.util.exec.Exec

public class Exec
extends Object

This stuff works, but it's probably not very clean when things go wrong. - Need to be more careful about handling InterruptedException and InterruptedIOException. - Need to be more careful with the I/O relay threads.


Nested Class Summary
static class Exec.ByteArrayInputSource
           
static class Exec.Handle
           
static class Exec.InputGenerator
           
static class Exec.InputStreamRelay
           
static class Exec.OutputCollector
           
static class Exec.OutputConsumer
           
static class Exec.OutputStreamRelay
           
static class Exec.StringInputSource
           
static class Exec.StringOutputCollector
           
 
Field Summary
static Exec.InputGenerator EmptyInput
           
static Exec.OutputConsumer OutputDiscarder
           
 
Constructor Summary
Exec(File workingDir, List<String> args)
           
Exec(File workingDir, String... args)
           
Exec(List<String> args)
           
Exec(String... args)
           
 
Method Summary
 Map<String,String> environment()
           
 Process launch()
           
static Exec.Handle launch(Exec.InputGenerator in, Exec.OutputConsumer out, Exec.OutputConsumer err, File workingDir, List<String> command)
           
static Exec.Handle launch(Exec.InputGenerator in, Exec.OutputConsumer out, Exec.OutputConsumer err, File workingDir, String... command)
           
static Exec.Handle launch(Exec.InputGenerator in, Exec.OutputConsumer out, Exec.OutputConsumer err, List<String> command)
           
static Exec.Handle launch(Exec.InputGenerator in, Exec.OutputConsumer out, Exec.OutputConsumer err, String... command)
           
static Process launch(File workingDir, List<String> command)
           
static Process launch(File workingDir, String... command)
           
static Process launch(List<String> command)
           
static Process launch(String... command)
           
static void relay(InputStream source, OutputStream target)
           
static void relay(InputStream source, OutputStream target, int bufferSize)
           
 void setRedirectErrorStream(boolean redirect)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EmptyInput

public static final Exec.InputGenerator EmptyInput

OutputDiscarder

public static final Exec.OutputConsumer OutputDiscarder
Constructor Detail

Exec

public Exec(File workingDir,
            String... args)

Exec

public Exec(String... args)

Exec

public Exec(File workingDir,
            List<String> args)

Exec

public Exec(List<String> args)
Method Detail

environment

public Map<String,String> environment()

launch

public Process launch()
               throws IOException
Throws:
IOException

setRedirectErrorStream

public void setRedirectErrorStream(boolean redirect)

launch

public static Process launch(File workingDir,
                             String... command)
                      throws IOException
Throws:
IOException

launch

public static Process launch(String... command)
                      throws IOException
Throws:
IOException

launch

public static Process launch(File workingDir,
                             List<String> command)
                      throws IOException
Throws:
IOException

launch

public static Process launch(List<String> command)
                      throws IOException
Throws:
IOException

launch

public static Exec.Handle launch(Exec.InputGenerator in,
                                 Exec.OutputConsumer out,
                                 Exec.OutputConsumer err,
                                 File workingDir,
                                 String... command)
                          throws IOException
Throws:
IOException

launch

public static Exec.Handle launch(Exec.InputGenerator in,
                                 Exec.OutputConsumer out,
                                 Exec.OutputConsumer err,
                                 String... command)
                          throws IOException
Throws:
IOException

launch

public static Exec.Handle launch(Exec.InputGenerator in,
                                 Exec.OutputConsumer out,
                                 Exec.OutputConsumer err,
                                 File workingDir,
                                 List<String> command)
                          throws IOException
Throws:
IOException

launch

public static Exec.Handle launch(Exec.InputGenerator in,
                                 Exec.OutputConsumer out,
                                 Exec.OutputConsumer err,
                                 List<String> command)
                          throws IOException
Throws:
IOException

relay

public static void relay(InputStream source,
                         OutputStream target)
                  throws IOException
Throws:
IOException

relay

public static void relay(InputStream source,
                         OutputStream target,
                         int bufferSize)
                  throws IOException
Throws:
IOException