|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream java.io.FilterInputStream org.apache.commons.io.input.ProxyInputStream org.apache.commons.io.input.TeeInputStream
public class TeeInputStream
InputStream proxy that transparently writes a copy of all bytes read
from the proxied stream to a given OutputStream. Using ProxyInputStream.skip(long)
or ProxyInputStream.mark(int)
/ProxyInputStream.reset()
on the stream will result on some
bytes from the input stream being skipped or duplicated in the output
stream.
The proxied input stream is closed when the close()
method is
called on this proxy. It is configurable whether the associated output
stream will also closed.
Field Summary |
---|
Fields inherited from class java.io.FilterInputStream |
---|
in |
Constructor Summary | |
---|---|
TeeInputStream(InputStream input,
OutputStream branch)
Creates a TeeInputStream that proxies the given InputStream
and copies all read bytes to the given OutputStream . |
|
TeeInputStream(InputStream input,
OutputStream branch,
boolean closeBranch)
Creates a TeeInputStream that proxies the given InputStream
and copies all read bytes to the given OutputStream . |
Method Summary | |
---|---|
void |
close()
Closes the proxied input stream and, if so configured, the associated output stream. |
int |
read()
Reads a single byte from the proxied input stream and writes it to the associated output stream. |
int |
read(byte[] bts)
Reads bytes from the proxied input stream and writes the read bytes to the associated output stream. |
int |
read(byte[] bts,
int st,
int end)
Reads bytes from the proxied input stream and writes the read bytes to the associated output stream. |
Methods inherited from class org.apache.commons.io.input.ProxyInputStream |
---|
afterRead, available, beforeRead, handleIOException, mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TeeInputStream(InputStream input, OutputStream branch)
InputStream
and copies all read bytes to the given OutputStream
. The given
output stream will not be closed when this stream gets closed.
input
- input stream to be proxiedbranch
- output stream that will receive a copy of all bytes readpublic TeeInputStream(InputStream input, OutputStream branch, boolean closeBranch)
InputStream
and copies all read bytes to the given OutputStream
. The given
output stream will be closed when this stream gets closed if the
closeBranch parameter is true
.
input
- input stream to be proxiedbranch
- output stream that will receive a copy of all bytes readcloseBranch
- flag for closing also the output stream when this
stream is closedMethod Detail |
---|
public void close() throws IOException
close
in interface Closeable
close
in class ProxyInputStream
IOException
- if either of the streams could not be closedpublic int read() throws IOException
read
in class ProxyInputStream
IOException
- if the stream could not be read (or written)public int read(byte[] bts, int st, int end) throws IOException
read
in class ProxyInputStream
bts
- byte bufferst
- start offset within the bufferend
- maximum number of bytes to read
IOException
- if the stream could not be read (or written)public int read(byte[] bts) throws IOException
read
in class ProxyInputStream
bts
- byte buffer
IOException
- if the stream could not be read (or written)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |