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
IOExceptionInputStream open() throws IOException
IOExceptionString encode() throws IOException
IOExceptionString encode(String charset) throws IOException
charset - this is the charset to encode the data withIOExceptionBuffer append(byte[] array) throws IOException
array - this is the byte array to append to this bufferIOExceptionBuffer 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 fromIOExceptionvoid clear()
throws IOException
IOExceptionvoid close()
throws IOException
IOExceptionlong length()
Copyright © 2024. All rights reserved.