|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
com.devexperts.io.BufferedInput
com.devexperts.io.ByteArrayInput
public class ByteArrayInput
An implementation of BufferedInput
using single byte array buffer.
Field Summary |
---|
Fields inherited from class com.devexperts.io.BufferedInput |
---|
buffer, EMPTY_BYTE_ARRAY, limit, markLimit, markPosition, position, totalPositionBase |
Constructor Summary | |
---|---|
ByteArrayInput()
Creates a new byte array input without pre-allocated buffer. |
|
ByteArrayInput(byte[] buf)
Creates a new byte array input with specified buffer as its input. |
|
ByteArrayInput(byte[] buf,
int offset,
int length)
Creates a new byte array input with specified buffer and range as its input. |
Method Summary | |
---|---|
void |
clear()
Clears this byte array input. |
void |
ensureCapacity(int requiredCapacity)
Ensures that the byte array used for buffering has at least the specified capacity. |
byte[] |
getBuffer()
Returns byte array used for buffering. |
int |
getLimit()
Returns limit. |
int |
getPosition()
Returns position. |
protected int |
readData()
This method is invoked when input methods need more bytes to read data. |
void |
rewind(long n)
Rewinds specified number of bytes. |
void |
setBuffer(byte[] newBuffer)
Sets specified byte array to be used for buffering. |
void |
setInput(byte[] buf,
int offset,
int length)
Sets specified buffer and range as an input. |
void |
setLimit(int newLimit)
Sets limit as specified. |
void |
setPosition(int newPosition)
Sets position as specified. |
void |
setTotalPosition(long totalPosition)
Sets total position as specified. |
Methods inherited from class com.devexperts.io.BufferedInput |
---|
available, checkEOB, checkRewind, mark, mark, markSupported, needData, read, read, read, readBoolean, readByte, readByteArray, readChar, readCompactInt, readCompactLong, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readObject, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTFChar, readUTFString, reset, seek, skip, skipBytes, throwEOFException, totalPosition |
Methods inherited from class java.io.InputStream |
---|
close |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.io.ObjectInput |
---|
close |
Constructor Detail |
---|
public ByteArrayInput()
public ByteArrayInput(byte[] buf)
buf
- the input bufferpublic ByteArrayInput(byte[] buf, int offset, int length)
offset
, the limit is set to offset+length
.
buf
- the input bufferoffset
- the offset in the buffer of the first byte to readlength
- the maximum number of bytes to read from the buffer
IllegalArgumentException
- if buf, offset and length do not constitute a valid rangeMethod Detail |
---|
protected int readData() throws IOException
BufferedInput
-1
if no bytes can be read because the end of the stream has been reached.
This method may block if needed.
This method is allowed to update buffer, position, limit and totalPositionBase fields as needed.
This method shall never throw an EOFException
.
readData
in class BufferedInput
-1
if there is no more data because the end of the stream has been reached
IOException
- if an I/O error occurspublic void setInput(byte[] buf, int offset, int length)
offset
,
the limit is set to offset+length
, the mark is invalidated.
buf
- the input bufferoffset
- the offset in the buffer of the first byte to readlength
- the maximum number of bytes to read from the buffer
IllegalArgumentException
- if buf, offset and length do not constitute a valid rangepublic byte[] getBuffer()
public void setBuffer(byte[] newBuffer)
public int getPosition()
public void setPosition(int newPosition)
IllegalArgumentException
- if the new position is negative or is larger than the limitpublic int getLimit()
public void setLimit(int newLimit)
IllegalArgumentException
- if the new limit is negative or is larger than the capacitypublic void setTotalPosition(long totalPosition)
IllegalArgumentException
- if the new total position is negativepublic void clear()
public void ensureCapacity(int requiredCapacity)
public void rewind(long n)
BufferedInput
rewind
in class BufferedInput
n
- the number of bytes to rewind
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |