public interface Buffer
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.
|
String |
encode()
This method is used to acquire the buffered bytes as a string.
|
String |
encode(String charset)
This method is used to acquire the buffered bytes as a string.
|
long |
length()
This is used to provide the number of bytes that have been
written to the buffer.
|
InputStream |
open()
This method is used so that a buffer can be represented as a
stream of bytes.
|
Buffer allocate() throws IOException
IOException
InputStream open() throws IOException
IOException
String encode() throws IOException
IOException
String encode(String charset) throws IOException
charset
- this is the charset to encode the data withIOException
Buffer append(byte[] array) throws IOException
array
- this is the byte array to append to this bufferIOException
Buffer append(byte[] array, int off, int len) throws 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 fromIOException
void clear() throws IOException
IOException
void close() throws IOException
IOException
long length()
Copyright © 2019. All rights reserved.