public abstract class AbstractBufferedInputStream extends FilterInputStream
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
The default buffer size in bytes
|
in
Constructor and Description |
---|
AbstractBufferedInputStream(InputStream in)
Create a new instance with the default buffer size
|
AbstractBufferedInputStream(InputStream in,
int size)
Creates a new instance with the given buffer size in bytes.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
assertBufferOpen() |
int |
available() |
protected abstract void |
clean()
Performs any necessary cleaning of the buffer and releasing of resources.
|
void |
close() |
protected abstract void |
compact(int markpos,
int size)
Compact the buffer reducing it to the given size, offset from the given mark position
|
protected abstract void |
get(byte[] b,
int pos,
int cnt)
Retrieve the given number of bytes from the stream
|
protected abstract int |
getInt(int position)
Reads four bytes (an int) from the given offset
|
protected int |
getMarkLimit() |
boolean |
isRestartable()
Indicates whether the stream can be restarted
|
protected abstract int |
limit()
Returns the buffer's limit
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
protected abstract void |
resizeBuffer(int position,
int newSize)
Enlarge the buffer to the new size, retaining the position
|
void |
restart()
Return the stream back to its start position
|
long |
skip(long n) |
protected abstract byte[] |
toArray()
Return the bytes in the buffer as a byte array
|
read
public static int DEFAULT_BUFFER_SIZE
public AbstractBufferedInputStream(InputStream in)
in
- InputStream to be wrappedBufferedInputStream.BufferedInputStream(InputStream)
public AbstractBufferedInputStream(InputStream in, int size)
in
- InputStream to be wrappedsize
- The size of the buffer in bytesBufferedInputStream.BufferedInputStream(InputStream, int)
protected abstract void assertBufferOpen() throws IOException
IOException
public int read() throws IOException
read
in class FilterInputStream
IOException
BufferedInputStream.read()
public int read(byte[] b, int off, int len) throws IOException
read
in class FilterInputStream
IOException
BufferedInputStream.read(byte[], int, int)
public long skip(long n) throws IOException
skip
in class FilterInputStream
IOException
BufferedInputStream.skip(long)
public int available() throws IOException
available
in class FilterInputStream
IOException
BufferedInputStream.available()
public void mark(int readlimit)
mark
in class FilterInputStream
BufferedInputStream.mark(int)
public void reset() throws IOException
reset
in class FilterInputStream
IOException
BufferedInputStream.reset()
public boolean markSupported()
markSupported
in class FilterInputStream
BufferedInputStream.markSupported()
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class FilterInputStream
IOException
BufferedInputStream.close()
public boolean isRestartable()
public void restart() throws IOException
IOException
- Indicates a problem occurred (e.g. the stream was closed)protected abstract void compact(int markpos, int size)
markpos
- The mark position to use as the start of the buffersize
- Required buffer sizeprotected abstract byte[] toArray()
protected abstract void resizeBuffer(int position, int newSize) throws IOException
position
- The positionnewSize
- The new sizeIOException
- Indicates a problem resizingprotected abstract int limit()
protected abstract int getInt(int position) throws IOException
position
- The offsetIOException
- Indicates a problem reading the intprotected abstract void get(byte[] b, int pos, int cnt)
b
- The array into which bytes will be writtenpos
- The offset within the array of the first byte to be writtencnt
- The maximum number of bytes to be written to the given arrayprotected abstract void clean()
protected int getMarkLimit()
Copyright © 2010–2018 Jadira Systems. All rights reserved.