Package cx.ath.matthew.io
Class TeeInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- cx.ath.matthew.io.TeeInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class TeeInputStream extends FilterInputStream
Class to copy a stream to a file or another stream as it is being sent through a stream pipe E.g.Reader r = new InputStreamReader(new TeeInputStream(new FileInputStream("file"), new File("otherfile")));
-
-
Constructor Summary
Constructors Constructor Description TeeInputStream(InputStream is, File f)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(InputStream is, File f, boolean append)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(InputStream is, OutputStream tos)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(InputStream is, String f)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(InputStream is, String f, boolean append)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.
-
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
-
TeeInputStream
public TeeInputStream(InputStream is, OutputStream tos) throws IOException
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.- Parameters:
is
- Reads from this InputStreamtos
- Write to this OutputStream- Throws:
IOException
-
TeeInputStream
public TeeInputStream(InputStream is, File f, boolean append) throws IOException
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.- Parameters:
is
- Reads from this InputStreamf
- Write to this Fileappend
- Append to file not overwrite- Throws:
IOException
-
TeeInputStream
public TeeInputStream(InputStream is, File f) throws IOException
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.- Parameters:
is
- Reads from this InputStreamf
- Write to this File- Throws:
IOException
-
TeeInputStream
public TeeInputStream(InputStream is, String f, boolean append) throws IOException
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.- Parameters:
is
- Reads from this InputStreamf
- Write to this Fileappend
- Append to file not overwrite- Throws:
IOException
-
TeeInputStream
public TeeInputStream(InputStream is, String f) throws IOException
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.- Parameters:
is
- Reads from this InputStreamf
- Write to this File- 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() throws IOException
- Overrides:
reset
in classFilterInputStream
- Throws:
IOException
-
-