public abstract class ByteUtilities
extends java.lang.Object
Constructor and Description |
---|
ByteUtilities() |
Modifier and Type | Method and Description |
---|---|
abstract byte[] |
fromBoolean(boolean value) |
abstract byte[] |
fromByte(byte value) |
abstract byte[] |
fromDouble(double value) |
abstract byte[] |
fromFloat(float value) |
abstract byte[] |
fromInt(int value) |
abstract byte[] |
fromLong(long value) |
abstract byte[] |
fromShort(short value) |
static ByteUtilities |
get(java.nio.ByteOrder order) |
abstract boolean |
getBoolean(byte[] data,
int offset) |
abstract byte |
getByte(byte[] data,
int offset) |
abstract double |
getDouble(byte[] data,
int offset) |
abstract float |
getFloat(byte[] data,
int offset) |
abstract int |
getInt(byte[] data,
int offset) |
abstract long |
getLong(byte[] data,
int offset) |
abstract short |
getShort(byte[] data,
int offset) |
static byte[] |
swapBytes(byte[] bs,
int offset)
Swaps the bytes at offset and offset+1 and returns a new byte[].
|
static byte[] |
swapWords(byte[] bs,
int offset)
Swaps the words starting at offset and offset+2 and returns a new byte[].
|
static java.lang.String |
toString(byte b)
Converts a byte to a hex string.
|
static java.lang.String |
toString(byte[] bs)
Converts a byte array into a hex string.
|
static java.lang.String |
toString(java.nio.ByteBuffer... buffers)
Converts multiple ByteBuffers into a hex string.
|
public static ByteUtilities get(java.nio.ByteOrder order)
public abstract boolean getBoolean(byte[] data, int offset)
public abstract byte getByte(byte[] data, int offset)
public abstract short getShort(byte[] data, int offset)
public abstract int getInt(byte[] data, int offset)
public abstract long getLong(byte[] data, int offset)
public abstract float getFloat(byte[] data, int offset)
public abstract double getDouble(byte[] data, int offset)
public abstract byte[] fromBoolean(boolean value)
public abstract byte[] fromByte(byte value)
public abstract byte[] fromShort(short value)
public abstract byte[] fromInt(int value)
public abstract byte[] fromLong(long value)
public abstract byte[] fromFloat(float value)
public abstract byte[] fromDouble(double value)
public static byte[] swapBytes(byte[] bs, int offset)
For example: Passing [1, 2, 3, 4,] and offset 1 would yield [3, 2].
bs
- The initial byte[].offset
- Offset into the byte[].public static byte[] swapWords(byte[] bs, int offset)
For example: Passing [1, 2, 3, 4,] and offset 1 would yield [3, 4, 1, 2].
bs
- The initial byte[].offset
- Offset into the byte[].public static java.lang.String toString(byte b)
b
- byte to convert.public static java.lang.String toString(byte[] bs)
bs
- byte[] to convert.public static java.lang.String toString(java.nio.ByteBuffer... buffers)