public class BranchingStreamWrapper extends BranchingInputStream
Note: This stream and any branches it creates are not safe for use by multiple concurrent threads.
Constructor and Description |
---|
BranchingStreamWrapper(InputStream in,
org.forgerock.util.Factory<Buffer> bufferFactory)
Constructs a new branching input stream to wrap another input stream.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without
blocking by the next invocation of a method for this input stream.
|
BranchingStreamWrapper |
branch()
Creates a new branch at this stream's current position.
|
void |
close()
Closes this branching stream and all of the branches created from it.
|
void |
finalize()
Closes this branching stream and all of the branches created from it.
|
BranchingStreamWrapper |
parent()
Returns the parent branching input stream from which this branch was
created, or
null if this is the trunk. |
int |
read()
Reads the next byte of data from the input stream.
|
int |
read(byte[] b)
Reads some number of bytes from the input stream and stores them into the buffer
array
b . |
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from the input stream into an array of bytes. |
long |
skip(long n)
Skips over and discards
n bytes of data from this input stream. |
mark, markSupported, reset
public BranchingStreamWrapper(InputStream in, org.forgerock.util.Factory<Buffer> bufferFactory)
If the stream being wrapped is a branching input stream, this constructor will simply branch off of that existing stream rather than wrapping it with another branching input stream.
in
- the stream to be wrapped.bufferFactory
- an object that can create new temporary buffers (e.g. @link TemporaryStorage}).public BranchingStreamWrapper branch() throws IOException
BranchingInputStream
branch
in class BranchingInputStream
IOException
- if an I/O exception occurs.public BranchingStreamWrapper parent()
BranchingInputStream
null
if this is the trunk.parent
in class BranchingInputStream
null
if this is the trunk.public int read() throws IOException
read
in class InputStream
-1
if the end of the stream is reached.IOException
- if an I/O exception occurs.public int read(byte[] b) throws IOException
b
.read
in class InputStream
b
- the buffer into which the data is read.-1
is there is no more data because the
end of the stream has been reached.IOException
- if an I/O exception occurs.public int read(byte[] b, int off, int len) throws IOException
len
bytes of data from the input stream into an array of bytes.read
in class InputStream
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes to read.-1
if there is no more data because the
end of the stream has been reached.IOException
- if an I/O exception occurs.public long skip(long n) throws IOException
n
bytes of data from this input stream.skip
in class InputStream
n
- the number of bytes to be skipped.IOException
- if an I/O exception occurs.public int available() throws IOException
available
in class InputStream
IOException
- if an I/O exception occurs.public void close() throws IOException
BranchingInputStream
close
in interface Closeable
close
in interface AutoCloseable
close
in class BranchingInputStream
IOException
- if an I/O exception occurs.Copyright © 2014 ForgeRock AS. All rights reserved.