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 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.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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterInputStream
- Throws:
IOException
-
flush
public void flush() throws IOException
- Throws:
IOException
-
available
public int available() throws IOException
- Overrides:
available
in classFilterInputStream
- Throws:
IOException
-
read
public int read() throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException
- Overrides:
read
in classFilterInputStream
- Throws:
IOException
-
skip
public long skip(long n) throws IOException
- Overrides:
skip
in classFilterInputStream
- Throws:
IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classFilterInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classFilterInputStream
-
reset
public void reset()
- Overrides:
reset
in classFilterInputStream
-
-