Class std.io.Buffer
Synopsis
public final class Buffer
A container for arbitrary data.
Fields
Constructors
Construct an empty buffer.
Construct a buffer of the specified initial size.
The contents are initially all zeroes.
Methods
Get the current size of the buffer.
Change the size of the buffer.
If the new size is shorter than the current size, then data at the end is truncated; if the new size is larger, then the buffer is padded with zero bytes at the end.
Arguments
newSize | The desired new size in bytes. |
---|
Update buffer contents.
The contents of the specified byte array are written at the specified byte position in the buffer. If the buffer is too small to fit the data there, it is automatically expanded to accomodate it.
Arguments
pos | Byte offset into the buffer where the array will be written. |
---|---|
bytes | Byte array to copy from. |
Read buffer contents.
The specified byte array will contain the data which has been read. This method begins reading at the specified position within the buffer, and contains until either the given byte array is full, or the end of the buffer was reached. It returns the number of bytes successfully read and places in the array.
Arguments
pos | Byte offset into the buffer where reading will begin. |
---|---|
bytes | Byte array to fill. |
Returns
The number of bytes read.