public class ByteBuffer extends Object
| Constructor and Description |
|---|
ByteBuffer(byte[] buffer) |
ByteBuffer(byte[] buffer,
int length) |
ByteBuffer(byte[] buffer,
int offset,
int length) |
ByteBuffer(InputStream in)
Loads the stream into a buffer.
|
ByteBuffer(int initialCapacity) |
| Modifier and Type | Method and Description |
|---|---|
void |
append(byte b)
Appends a byte to the buffer.
|
void |
append(byte[] bytes)
Append a byte array to the buffer
|
void |
append(byte[] bytes,
int offset,
int len)
Appends a part of byte array to the buffer.
|
void |
append(ByteBuffer anotherBuffer)
Append another buffer to this buffer.
|
byte |
byteAt(int index) |
int |
charAt(int index) |
InputStream |
getByteStream() |
String |
getEncoding()
Detects the encoding of the byte buffer, stores and returns it.
|
int |
length() |
public ByteBuffer(int initialCapacity)
initialCapacity - the initial capacity for this bufferpublic ByteBuffer(byte[] buffer)
buffer - a byte array that will be wrapped with ByteBuffer.public ByteBuffer(byte[] buffer,
int length)
buffer - a byte array that will be wrapped with ByteBuffer.length - the length of valid bytes in the arraypublic ByteBuffer(InputStream in) throws IOException
in - an InputStreamIOException - If the stream cannot be read.public ByteBuffer(byte[] buffer,
int offset,
int length)
buffer - a byte array that will be wrapped with ByteBuffer.offset - the offset of the provided buffer.length - the length of valid bytes in the arraypublic InputStream getByteStream()
public int length()
public byte byteAt(int index)
index - the index to retrieve the byte frompublic int charAt(int index)
index - the index to retrieve a byte as int or char.public void append(byte b)
b - a bytepublic void append(byte[] bytes,
int offset,
int len)
offset
through offset+len-1 of provided array will be copiedbytes - a byte arrayoffset - is a position of the first element to copylen - the number of array elements to be addedpublic void append(byte[] bytes)
bytes - a byte arraypublic void append(ByteBuffer anotherBuffer)
anotherBuffer - another ByteBufferpublic String getEncoding()
Copyright © 1998–2025 Apryse Group NV. All rights reserved.