public class SplittableInputStream extends InputStream
getInputStream(int)) (that also yield the same bytes).
|Constructor and Description|
Wraps an input stream so that copy streams can be split off.
|Modifier and Type||Method and Description|
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.
Closes this input stream and releases any system resources associated with the stream.
Returns the number of buffered bytes in the underlying buffer.
Gets a copy of the inputstream positioned at
Returns the length of the underlying buffer.
Returns the position within the input stream (the number of bytes read since this input stream was constructed).
Marks the current position in this input stream.
Tests if this input stream supports the
Reads the next byte of data from the input stream.
Repositions this stream to the position at the time the
Skips over and discards
Updates this stream's buffer based on some other stream's buffer.
public SplittableInputStream(InputStream inputStream, int length)
inputStream- the original input stream
length- the precise length of bytes that the original input stream provides
public void updateFrom(SplittableInputStream other)
other- the other stream
public InputStream getInputStream(int position)
position- a position between
public int getPosition()
public int read() throws IOException
intin the range
255. If no byte is available because the end of the stream has been reached, the value
-1is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
public long skip(long n) throws IOException
nbytes of data from this input stream. The
skipmethod may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly
0. This may result from any of a number of conditions; reaching end of file before
nbytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If
nis negative, no bytes are skipped.
public int available() throws IOException
public void close() throws IOException
public void mark(int readlimit)
resetmethod repositions this stream at the last marked position so that subsequent reads re-read the same bytes.
readlimit arguments tells this input stream to
allow that many bytes to be read before the mark position gets
The general contract of
mark is that, if the method
true, the stream somehow
remembers all the bytes read after the call to
stands ready to supply those same bytes again if and whenever the method
reset is called. However, the stream is not required to
remember any data at all if more than
readlimit bytes are
read from the stream before
reset is called.
public void reset() throws IOException
markmethod was last called on this input stream. The general contract of
markhas not been called since the stream was created, or the number of bytes read from the stream since
markwas last called is larger than the argument to
markat that last call, then an
IOExceptionmight be thrown.
IOExceptionis not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to
mark(or since the start of the file, if
markhas not been called) will be resupplied to subsequent callers of the
readmethod, followed by any bytes that otherwise would have been the next input data as of the time of the call to
resetmay throw an
IOExceptionis not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the
readmethod depend on the particular type of the input stream.
public boolean markSupported()
resetmethods. Whether or not
resetare supported is an invariant property of a particular input stream instance. The
public int getLength()
public int getBytesBuffered()
Copyright © 2018. All rights reserved.