Package cx.ath.matthew.io
Class ExecInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- cx.ath.matthew.io.ExecInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class ExecInputStream extends java.io.FilterInputStreamClass to pipe an InputStream through a command using stdin/stdout. E.g.Reader r = new InputStreamReader(new ExecInputStream(new FileInputStream("file"), "command"));
-
-
Constructor Summary
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()voidfinalize()voidflush()voidmark(int readlimit)booleanmarkSupported()intread()intread(byte[] b)intread(byte[] b, int off, int len)voidreset()longskip(long n)
-
-
-
Constructor Detail
-
ExecInputStream
public ExecInputStream(java.io.InputStream is, java.lang.Process p) throws java.io.IOExceptionCreate a new ExecInputStream on the given InputStream using the process to filter the stream.- Parameters:
is- Reads from this InputStreamp- 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.IOExceptionCreate a new ExecInputStream on the given InputStream using the process to filter the stream.- Parameters:
is- Reads from this InputStreamcmd- 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.IOExceptionCreate a new ExecInputStream on the given InputStream using the process to filter the stream.- Parameters:
is- Reads from this InputStreamcmd- 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.IOExceptionCreate a new ExecInputStream on the given InputStream using the process to filter the stream.- Parameters:
is- Reads from this InputStreamcmd- Creates a Process from this string to filter data through stdin/outenv- 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.IOExceptionCreate a new ExecInputStream on the given InputStream using the process to filter the stream.- Parameters:
is- Reads from this InputStreamcmd- Creates a Process from this string array (command, arg, ...) to filter data through stdin/outenv- Setup the environment for the command- Throws:
java.io.IOException
-
-
Method Detail
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.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:
availablein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classjava.io.FilterInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.FilterInputStream
-
reset
public void reset()
- Overrides:
resetin classjava.io.FilterInputStream
-
finalize
public void finalize()
- Overrides:
finalizein classjava.lang.Object
-
-