public class ByteWriter extends Object
| Constructor and Description |
|---|
ByteWriter()
Default constructor.
|
ByteWriter(int capacity)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBytes()
Retrieve all of the bytes that have been written to this instance.
|
byte[] |
getBytes(int off)
Retrieve the bytes that have been written to this instance, starting at the given offset.
|
byte[] |
getBytes(int off,
int len)
Retrieve a sub-range of the bytes that have been written to this instance.
|
int |
getLength()
Get the current buffer length.
|
int |
mark()
Mark current position.
|
void |
reset(int mark)
Reset write position to a previously marked position.
|
void |
write(byte[] data)
Write an array of bytes to this instance.
|
void |
write(byte[] data,
int off,
int len)
Write a sub-range from an array of bytes.
|
void |
write(ByteReader reader)
Read all remaining content from the given
ByteReader and write it to this instance. |
void |
writeByte(int value)
Write a single byte to this instance.
|
public ByteWriter()
public ByteWriter(int capacity)
capacity - initial capacity of bufferpublic byte[] getBytes()
public byte[] getBytes(int off)
off - offset into written bytesoff (not necessarily a copy; caller must not modify)IndexOutOfBoundsException - if off or len is out of boundspublic byte[] getBytes(int off,
int len)
off - offset into written byteslen - desired lengthlen bytes written so far starting from off (not necessarily a copy; caller must not modify)IndexOutOfBoundsException - if off or len is out of boundspublic void writeByte(int value)
value - byte to write; all but the lower 8 bits are ignoredpublic void write(ByteReader reader)
ByteReader and write it to this instance.reader - source for bytes to writepublic void write(byte[] data)
data - bytes to writepublic void write(byte[] data,
int off,
int len)
data - bytes to writeoff - offset into datalen - the number of bytes to writeIndexOutOfBoundsException - if off or len is out of boundspublic int getLength()
#mark.public int mark()
#getLength.public void reset(int mark)
mark - value previously returned by mark()IndexOutOfBoundsException - if mark is out of boundsCopyright © 2016. All rights reserved.