Class CircularBufferInputStream
- java.lang.Object
-
- java.io.InputStream
-
- org.apache.commons.io.input.buffer.CircularBufferInputStream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
- Direct Known Subclasses:
PeekableInputStream
public class CircularBufferInputStream extends InputStream
Implements a buffered input stream, which is internally based on aCircularByteBuffer. Unlike theBufferedInputStream, this one doesn't need to reallocate byte arrays internally.
-
-
Constructor Summary
Constructors Constructor Description CircularBufferInputStream(InputStream inputStream)Creates 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)Creates a new instance, which filters the given input stream, and uses the given buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intread()intread(byte[] buffer)intread(byte[] targetBuffer, int offset, int length)-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
CircularBufferInputStream
public CircularBufferInputStream(InputStream inputStream, int bufferSize)
Creates 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 theCircularByteBuffer, which is used internally.
-
CircularBufferInputStream
public CircularBufferInputStream(InputStream inputStream)
Creates 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.
-
-
Method Detail
-
read
public int read() throws IOException- Specified by:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] buffer) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
read
public int read(byte[] targetBuffer, int offset, int length) throws IOException- Overrides:
readin classInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
-