public class OldByteUtilities
extends java.lang.Object
Constructor and Description |
---|
OldByteUtilities() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
fromDouble(double value,
java.nio.ByteOrder order)
Convert a double value into an 8-byte byte[] in the given ByteOrder.
|
static byte[] |
fromFloat(float value,
java.nio.ByteOrder order)
Convert a float value into a 4-byte byte[] in the given ByteOrder.
|
static byte[] |
fromInt(int value,
java.nio.ByteOrder order)
Convert an int value into a 4-byte byte[] in the given ByteOrder.
|
static byte[] |
fromLong(long value,
java.nio.ByteOrder order)
Convert a long value into an 8-byte byte[] in the given ByteOrder.
|
static byte[] |
fromShort(short value,
java.nio.ByteOrder order)
Convert a short value into a 2-byte byte[] in the given ByteOrder.
|
static boolean |
getBoolean(byte[] data)
Extracts a boolean from the first byte of a byte[].
|
static boolean |
getBoolean(byte[] data,
int offset)
Extracts a byte from the first byte of a byte[], starting at the given offset.
|
static byte |
getByte(byte[] data)
Extracts a byte from the first byte of a byte[].
|
static byte |
getByte(byte[] data,
int offset)
Extracts a byte from the first byte of a byte[], starting at the given offset.
|
static double |
getDouble(byte[] data,
java.nio.ByteOrder order)
Extracts a double value from the first 2 bytes of a byte[].
|
static double |
getDouble(byte[] data,
int offset,
java.nio.ByteOrder order)
Extracts a double value from the first 8 bytes of a byte[], starting at the given offset.
|
static float |
getFloat(byte[] data,
java.nio.ByteOrder order)
Extracts a float value from the first 2 bytes of a byte[].
|
static float |
getFloat(byte[] data,
int offset,
java.nio.ByteOrder order)
Extracts a float value from the first 4 bytes of a byte[], starting at the given offset.
|
static int |
getInt(byte[] data,
java.nio.ByteOrder order)
Extracts an int from the first 4 bytes of a byte[].
|
static int |
getInt(byte[] data,
int offset,
java.nio.ByteOrder order)
Extracts an int value from the first 4 bytes of a byte[], starting at the given offset.
|
static long |
getLong(byte[] data,
java.nio.ByteOrder order)
Extracts a long value from the first 8 bytes of a byte[].
|
static long |
getLong(byte[] data,
int offset,
java.nio.ByteOrder order)
Extracts a long value from the first 8 bytes of a byte[], starting at the given offset.
|
static short |
getShort(byte[] data,
java.nio.ByteOrder order)
Extracts a short from the first 2 bytes of a byte[].
|
static short |
getShort(byte[] data,
int offset,
java.nio.ByteOrder order)
Extracts a short value from the first 2 bytes of a byte[], starting at the given offset.
|
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 boolean getBoolean(byte[] data)
data
- byte[] to extract from.public static boolean getBoolean(byte[] data, int offset)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.public static byte getByte(byte[] data)
data
- byte[] to extract from.public static byte getByte(byte[] data, int offset)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.public static short getShort(byte[] data, java.nio.ByteOrder order)
data
- byte[] to extract from.order
- ByteOrder to use.public static short getShort(byte[] data, int offset, java.nio.ByteOrder order)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.order
- ByteOrder to use.public static int getInt(byte[] data, java.nio.ByteOrder order)
data
- byte[] to extract from.order
- ByteOrder to use.public static int getInt(byte[] data, int offset, java.nio.ByteOrder order)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.order
- ByteOrder to use.public static long getLong(byte[] data, java.nio.ByteOrder order)
data
- byte[] to extract from.order
- ByteOrder to use.public static long getLong(byte[] data, int offset, java.nio.ByteOrder order)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.order
- ByteOrder to use.public static float getFloat(byte[] data, java.nio.ByteOrder order)
data
- byte[] to extract from.order
- ByteOrder to use.public static float getFloat(byte[] data, int offset, java.nio.ByteOrder order)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.order
- ByteOrder to use.public static double getDouble(byte[] data, java.nio.ByteOrder order)
data
- byte[] to extract from.order
- ByteOrder to use.public static double getDouble(byte[] data, int offset, java.nio.ByteOrder order)
data
- byte[] to extract from.offset
- Offset into the byte[] to start at.order
- ByteOrder to use.public static byte[] fromShort(short value, java.nio.ByteOrder order)
value
- short to convert.order
- ByteOrder to use.public static byte[] fromInt(int value, java.nio.ByteOrder order)
value
- int to convert.order
- ByteOrder to use.public static byte[] fromLong(long value, java.nio.ByteOrder order)
value
- long to convert.order
- ByteOrder to use.public static byte[] fromFloat(float value, java.nio.ByteOrder order)
value
- float to convert.order
- ByteOrder to use.public static byte[] fromDouble(double value, java.nio.ByteOrder order)
value
- double to convert.order
- ByteOrder to use.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)
buffers
-