Class CircularBufferInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
org.apache.commons.io.input.buffer.CircularBufferInputStream
- All Implemented Interfaces:
- Closeable,- AutoCloseable
- Direct Known Subclasses:
- PeekableInputStream
Implements a buffered input stream, which is internally based on a 
CircularByteBuffer. Unlike the
 BufferedInputStream, this one doesn't need to reallocate byte arrays internally.- Since:
- 2.7
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final CircularByteBufferInternal buffer.protected final intInternal buffer size.Fields inherited from class java.io.FilterInputStreamin
- 
Constructor SummaryConstructorsConstructorDescriptionCircularBufferInputStream(InputStream inputStream) Constructs a new instance, which filters the given input stream, and uses a reasonable default buffer size (IOUtils.DEFAULT_BUFFER_SIZE).CircularBufferInputStream(InputStream inputStream, int bufferSize) Constructs a new instance, which filters the given input stream, and uses the given buffer size.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()protected voidFills the buffer with the contents of the input stream.protected booleanhaveBytes(int count) Fills the buffer from the input stream until the given number of bytes have been added to the buffer.intread()intread(byte[] targetBuffer, int offset, int length) Methods inherited from class java.io.FilterInputStreamavailable, mark, markSupported, read, reset, skip
- 
Field Details- 
bufferInternal buffer.
- 
bufferSizeInternal buffer size.
 
- 
- 
Constructor Details- 
CircularBufferInputStreamConstructs a new instance, which filters the given input stream, and uses a reasonable default buffer size (IOUtils.DEFAULT_BUFFER_SIZE).- Parameters:
- inputStream- The input stream, which is being buffered.
 
- 
CircularBufferInputStreamConstructs a new instance, which filters the given input stream, and uses the given buffer size.- Parameters:
- inputStream- The input stream, which is being buffered.
- bufferSize- The size of the- CircularByteBuffer, which is used internally.
 
 
- 
- 
Method Details- 
close- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- FilterInputStream
- Throws:
- IOException
 
- 
fillBufferFills the buffer with the contents of the input stream.- Throws:
- IOException- in case of an error while reading from the input stream.
 
- 
haveBytesFills the buffer from the input stream until the given number of bytes have been added to the buffer.- Parameters:
- count- number of byte to fill into the buffer
- Returns:
- true if the buffer has bytes
- Throws:
- IOException- in case of an error while reading from the input stream.
 
- 
read- Overrides:
- readin class- FilterInputStream
- Throws:
- IOException
 
- 
read- Overrides:
- readin class- FilterInputStream
- Throws:
- IOException
 
 
-