Package cx.ath.matthew.io
Class TeeInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- cx.ath.matthew.io.TeeInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class TeeInputStream extends java.io.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(java.io.InputStream is, java.io.File f)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(java.io.InputStream is, java.io.File f, boolean append)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(java.io.InputStream is, java.io.OutputStream tos)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(java.io.InputStream is, java.lang.String f)
Create a new TeeInputStream on the given InputStream and copy the stream to the given File.TeeInputStream(java.io.InputStream is, java.lang.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)
-
-
-
Constructor Detail
-
TeeInputStream
public TeeInputStream(java.io.InputStream is, java.io.OutputStream tos) throws java.io.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:
java.io.IOException
-
TeeInputStream
public TeeInputStream(java.io.InputStream is, java.io.File f, boolean append) throws java.io.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:
java.io.IOException
-
TeeInputStream
public TeeInputStream(java.io.InputStream is, java.io.File f) throws java.io.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:
java.io.IOException
-
TeeInputStream
public TeeInputStream(java.io.InputStream is, java.lang.String f, boolean append) throws java.io.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:
java.io.IOException
-
TeeInputStream
public TeeInputStream(java.io.InputStream is, java.lang.String f) throws java.io.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:
java.io.IOException
-
-
Method Detail
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in 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:
available
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read() throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
read
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException
- Overrides:
skip
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
mark
public void mark(int readlimit)
- Overrides:
mark
in classjava.io.FilterInputStream
-
markSupported
public boolean markSupported()
- Overrides:
markSupported
in classjava.io.FilterInputStream
-
reset
public void reset() throws java.io.IOException
- Overrides:
reset
in classjava.io.FilterInputStream
- Throws:
java.io.IOException
-
finalize
public void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
-