public class TeeInputStream extends ProxyInputStream
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.
ObservableInputStream
Constructor and Description |
---|
TeeInputStream(java.io.InputStream input,
java.io.OutputStream branch)
Creates a TeeInputStream that proxies the given
InputStream
and copies all read bytes to the given OutputStream . |
TeeInputStream(java.io.InputStream input,
java.io.OutputStream branch,
boolean closeBranch)
Creates a TeeInputStream that proxies the given
InputStream
and copies all read bytes to the given OutputStream . |
Modifier and Type | Method and Description |
---|---|
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.
|
available, mark, markSupported, reset, skip
public TeeInputStream(java.io.InputStream input, java.io.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(java.io.InputStream input, java.io.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 closedpublic void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in class ProxyInputStream
java.io.IOException
- if either of the streams could not be closedpublic int read() throws java.io.IOException
read
in class ProxyInputStream
java.io.IOException
- if the stream could not be read (or written)public int read(byte[] bts, int st, int end) throws java.io.IOException
read
in class ProxyInputStream
bts
- byte bufferst
- start offset within the bufferend
- maximum number of bytes to readjava.io.IOException
- if the stream could not be read (or written)public int read(byte[] bts) throws java.io.IOException
read
in class ProxyInputStream
bts
- byte bufferjava.io.IOException
- if the stream could not be read (or written)Copyright © 2010 - 2020 Adobe. All Rights Reserved