public interface Bytes extends BytesInput<Bytes>, BytesOutput<Bytes>, AutoCloseable
| Modifier and Type | Field and Description |
|---|---|
static int |
BOOLEAN |
static int |
BYTE |
static int |
CHARACTER |
static int |
DOUBLE |
static int |
FLOAT |
static int |
INTEGER |
static int |
LONG |
static int |
MEDIUM |
static int |
SHORT |
| Modifier and Type | Method and Description |
|---|---|
default byte[] |
array()
Returns the underlying byte array.
|
void |
close() |
default boolean |
hasArray()
Returns whether the bytes has an array.
|
boolean |
isDirect()
Returns a boolean value indicating whether the bytes are direct.
|
boolean |
isFile()
Returns a boolean value indicating whether the bytes are backed by a file.
|
ByteOrder |
order()
Returns the byte order.
|
Bytes |
order(ByteOrder order)
Sets the byte order, returning a new swapped
Bytes instance. |
Bytes |
resize(int newSize)
Resizes the bytes.
|
int |
size()
Returns the count of the bytes.
|
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readInt, readLong, readMedium, readShort, readString, readString, readUnsignedByte, readUnsignedInt, readUnsignedMedium, readUnsignedShort, readUTF8flush, write, write, writeBoolean, writeByte, writeChar, writeDouble, writeFloat, writeInt, writeLong, writeMedium, writeShort, writeString, writeString, writeUnsignedByte, writeUnsignedInt, writeUnsignedMedium, writeUnsignedShort, writeUTF8, zero, zero, zerostatic final int BYTE
static final int BOOLEAN
static final int CHARACTER
static final int SHORT
static final int MEDIUM
static final int INTEGER
static final int LONG
static final int FLOAT
static final int DOUBLE
default boolean hasArray()
default byte[] array()
UnsupportedOperationException - if a heap array is not supportedint size()
Bytes resize(int newSize)
When the bytes are resized, underlying memory addresses in copies of this instance may no longer be valid. Additionally,
if the newSize is smaller than the current count then some data may be lost during the resize. Use
with caution.
newSize - The count to which to resize this instance.ByteOrder order()
For consistency with ByteBuffer, all bytes implementations are initially in ByteOrder.BIG_ENDIAN order.
Bytes order(ByteOrder order)
Bytes instance.
By default, all bytes are read and written in ByteOrder.BIG_ENDIAN order. This provides complete
consistency with ByteBuffer. To flip bytes to ByteOrder.LITTLE_ENDIAN order, this
Bytes instance is decorated by a SwappedBytes instance which will reverse
read and written bytes using, e.g. Integer.reverseBytes(int).
order - The byte order.NullPointerException - If the order is nullboolean isDirect()
boolean isFile()
void close()
close in interface AutoCloseableCopyright © 2013–2018. All rights reserved.