cx.ath.matthew.io
Class ExecInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by cx.ath.matthew.io.ExecInputStream
All Implemented Interfaces:
java.io.Closeable

public class ExecInputStream
extends java.io.FilterInputStream

Class to pipe an InputStream through a command using stdin/stdout. E.g.

    Reader r = new InputStreamReader(new ExecInputStream(new FileInputStream("file"), "command"));
 


Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
ExecInputStream(java.io.InputStream is, java.lang.Process p)
          Create a new ExecInputStream on the given InputStream using the process to filter the stream.
ExecInputStream(java.io.InputStream is, java.lang.String cmd)
          Create a new ExecInputStream on the given InputStream using the process to filter the stream.
ExecInputStream(java.io.InputStream is, java.lang.String[] cmd)
          Create a new ExecInputStream on the given InputStream using the process to filter the stream.
ExecInputStream(java.io.InputStream is, java.lang.String[] cmd, java.lang.String[] env)
          Create a new ExecInputStream on the given InputStream using the process to filter the stream.
ExecInputStream(java.io.InputStream is, java.lang.String cmd, java.lang.String[] env)
          Create a new ExecInputStream on the given InputStream using the process to filter the stream.
 
Method Summary
 int available()
           
 void close()
           
 void finalize()
           
 void flush()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecInputStream

public ExecInputStream(java.io.InputStream is,
                       java.lang.Process p)
                throws java.io.IOException
Create a new ExecInputStream on the given InputStream using the process to filter the stream.

Parameters:
is - Reads from this InputStream
p - Filters data through stdin/out on this Process
Throws:
java.io.IOException

ExecInputStream

public ExecInputStream(java.io.InputStream is,
                       java.lang.String cmd)
                throws java.io.IOException
Create a new ExecInputStream on the given InputStream using the process to filter the stream.

Parameters:
is - Reads from this InputStream
cmd - Creates a Process from this string to filter data through stdin/out
Throws:
java.io.IOException

ExecInputStream

public ExecInputStream(java.io.InputStream is,
                       java.lang.String[] cmd)
                throws java.io.IOException
Create a new ExecInputStream on the given InputStream using the process to filter the stream.

Parameters:
is - Reads from this InputStream
cmd - Creates a Process from this string array (command, arg, ...) to filter data through stdin/out
Throws:
java.io.IOException

ExecInputStream

public ExecInputStream(java.io.InputStream is,
                       java.lang.String cmd,
                       java.lang.String[] env)
                throws java.io.IOException
Create a new ExecInputStream on the given InputStream using the process to filter the stream.

Parameters:
is - Reads from this InputStream
cmd - Creates a Process from this string to filter data through stdin/out
env - Setup the environment for the command
Throws:
java.io.IOException

ExecInputStream

public ExecInputStream(java.io.InputStream is,
                       java.lang.String[] cmd,
                       java.lang.String[] env)
                throws java.io.IOException
Create a new ExecInputStream on the given InputStream using the process to filter the stream.

Parameters:
is - Reads from this InputStream
cmd - Creates a Process from this string array (command, arg, ...) to filter data through stdin/out
env - Setup the environment for the command
Throws:
java.io.IOException
Method Detail

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.FilterInputStream
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.FilterInputStream
Throws:
java.io.IOException

skip

public long skip(long n)
          throws java.io.IOException
Overrides:
skip in class java.io.FilterInputStream
Throws:
java.io.IOException

mark

public void mark(int readlimit)
Overrides:
mark in class java.io.FilterInputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.FilterInputStream

reset

public void reset()
Overrides:
reset in class java.io.FilterInputStream

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object