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 byte array or part of 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 buffer
public 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 array
public ByteBuffer(InputStream in) throws IOException
in
- an InputStream
IOException
- 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 array
public InputStream getByteStream()
public int length()
public byte byteAt(int index)
index
- the index to retrieve the byte from
public int charAt(int index)
index
- the index to retrieve a byte as int or char.
public void append(byte b)
b
- a byte
public void append(byte[] bytes, int offset, int len)
bytes
- a byte array
offset
- an offset with
len
-
public void append(byte[] bytes)
bytes
- a byte array
public void append(ByteBuffer anotherBuffer)
anotherBuffer
- another ByteBuffer
public String getEncoding()
Copyright © 1998–2019. All rights reserved.