public class ByteReader extends Object
| Constructor and Description |
|---|
ByteReader(byte[] buf)
Constructor.
|
ByteReader(byte[] buf,
int off)
Constructor.
|
ByteReader(byte[] buf,
int off,
int len)
Constructor.
|
ByteReader(ByteWriter writer)
Constructor.
|
ByteReader(ByteWriter writer,
int mark)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBytes()
Copy all the of bytes in the buffer.
|
byte[] |
getBytes(int off)
Copy a range of bytes from the given offset to the end of the buffer.
|
byte[] |
getBytes(int off,
int len)
Copy a range of bytes from the buffer.
|
int |
getMax()
Get maximum offset into buffer.
|
int |
getOffset()
Get current offset into buffer.
|
int |
mark()
Mark current read position.
|
int |
peek()
Peek at next byte, if any.
|
int |
readByte()
Read the next byte.
|
byte[] |
readBytes(int len)
Read the specified number of bytes.
|
int |
remain()
Get the number of bytes remaining.
|
void |
reset(int mark)
Reset read position to a previously marked position.
|
void |
skip(int num)
Skip over bytes.
|
void |
unread()
Unread the previously read byte.
|
void |
unread(int len)
Unread the given number of previously read bytes.
|
public ByteReader(byte[] buf)
buf - array to read fromNullPointerException - if buf is nullpublic ByteReader(byte[] buf,
int off)
buf - array to read fromoff - starting offset into bufIndexOutOfBoundsException - if off is out of boundsNullPointerException - if buf is nullpublic ByteReader(byte[] buf,
int off,
int len)
buf - array to read fromoff - offset into buflen - number of bytes to readIndexOutOfBoundsException - if off or len are out of boundsNullPointerException - if buf is nullpublic ByteReader(ByteWriter writer)
writer - ByteWriter to read data fromNullPointerException - if writer is nullpublic ByteReader(ByteWriter writer, int mark)
writer - ByteWriter to read data frommark - position previously returned by ByteWriter#markIndexOutOfBoundsException - if mark is out of boundsNullPointerException - if writer is nullpublic int peek()
IndexOutOfBoundsException - if there are no more bytespublic int readByte()
IndexOutOfBoundsException - if there are no more bytespublic void unread()
unread(1).IndexOutOfBoundsException - if there are no more bytes to unreadpublic void unread(int len)
len - the number of bytes to unreadIndexOutOfBoundsException - if there are no more bytes to unreadpublic byte[] readBytes(int len)
len - number of bytes to readIndexOutOfBoundsException - if there are not enough bytesIllegalArgumentException - if len is negativepublic int remain()
public void skip(int num)
num - the number of bytes to skipIndexOutOfBoundsException - if num is negativeIndexOutOfBoundsException - if less than num bytes remainpublic int getOffset()
public int getMax()
public byte[] getBytes(int off,
int len)
off - offset into bufferlen - number of bytesIndexOutOfBoundsException - if off and/or len is out of boundspublic byte[] getBytes(int off)
off - offset into bufferIndexOutOfBoundsException - if off is out of boundspublic byte[] getBytes()
public int mark()
public void reset(int mark)
mark - value previously returned by mark()IndexOutOfBoundsException - if mark is out of boundsCopyright © 2016. All rights reserved.