public interface Buffer extends Stream
Buffer
interface represents a collection of bytes
that can be written to and later read. This is used to provide a
region of memory is such a way that the underlying representation
of that memory is independent of its use. Typically buffers are
implemented as either allocated byte arrays or files.Allocator
Modifier and Type | Method and Description |
---|---|
Buffer |
allocate()
This method is used to allocate a segment of this buffer as a
separate buffer object.
|
Buffer |
append(byte[] array)
This method is used to append bytes to the end of the buffer.
|
Buffer |
append(byte[] array,
int off,
int len)
This method is used to append bytes to the end of the buffer.
|
void |
clear()
This will clear all data from the buffer.
|
void |
close()
This method is used to ensure the buffer can be closed.
|
java.lang.String |
encode()
This method is used to acquire the buffered bytes as a string.
|
java.lang.String |
encode(java.lang.String charset)
This method is used to acquire the buffered bytes as a string.
|
getInputStream
Buffer allocate() throws java.io.IOException
java.io.IOException
java.lang.String encode() throws java.io.IOException
java.io.IOException
java.lang.String encode(java.lang.String charset) throws java.io.IOException
charset
- this is the charset to encode the data withjava.io.IOException
Buffer append(byte[] array) throws java.io.IOException
array
- this is the byte array to append to this bufferjava.io.IOException
Buffer append(byte[] array, int off, int len) throws java.io.IOException
array
- this is the byte array to append to this bufferlen
- the number of bytes to be read from the arrayoff
- this is the offset to begin reading the bytes fromjava.io.IOException
void clear() throws java.io.IOException
java.io.IOException
void close() throws java.io.IOException
java.io.IOException