Package cx.ath.matthew.io
Class ExecInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- cx.ath.matthew.io.ExecInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class ExecInputStream extends 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
Constructors Constructor Description ExecInputStream(InputStream is, Process p)Create a new ExecInputStream on the given InputStream using the process to filter the stream.ExecInputStream(InputStream is, String cmd)Create a new ExecInputStream on the given InputStream using the process to filter the stream.ExecInputStream(InputStream is, String[] cmd)Create a new ExecInputStream on the given InputStream using the process to filter the stream.ExecInputStream(InputStream is, String[] cmd, String[] env)Create a new ExecInputStream on the given InputStream using the process to filter the stream.ExecInputStream(InputStream is, String cmd, 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)-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
ExecInputStream
public ExecInputStream(InputStream is, Process p) throws IOException
Create 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:
IOException
-
ExecInputStream
public ExecInputStream(InputStream is, String cmd) throws IOException
Create 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:
IOException
-
ExecInputStream
public ExecInputStream(InputStream is, String[] cmd) throws IOException
Create 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:
IOException
-
ExecInputStream
public ExecInputStream(InputStream is, String cmd, String[] env) throws IOException
Create 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:
IOException
-
ExecInputStream
public ExecInputStream(InputStream is, String[] cmd, String[] env) throws IOException
Create 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:
IOException
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
flush
public void flush() throws IOException- Throws:
IOException
-
available
public int available() throws IOException- Overrides:
availablein classFilterInputStream- Throws:
IOException
-
read
public int read() throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
skip
public long skip(long n) throws IOException- Overrides:
skipin classFilterInputStream- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
markin classFilterInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classFilterInputStream
-
reset
public void reset()
- Overrides:
resetin classFilterInputStream
-
-