public final class ByteUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static void |
clear(byte[] b)
Clears the values in the given byte array.
|
static void |
clear(char[] c)
Clears the values in the given char array.
|
static byte[] |
copy(byte[] b)
Returns a copy of the given byte array.
|
static byte[] |
copy(byte[] b,
int offset,
int length)
Returns a copy of the given byte array using the given offset and length.
|
static byte[] |
toBytes(double number)
Converts a double to its byte array representation.
|
static byte[] |
toBytes(float number)
Converts a float to its byte array representation.
|
static byte[] |
toBytes(int number)
Converts an integer to its byte array representation.
|
static byte[] |
toBytes(long number)
Converts a long to its byte array representation.
|
static byte[] |
toBytes(short number)
Converts a short to its byte array representation.
|
static double |
toDouble(byte[] bytes)
Converts a byte array to a double.
|
static float |
toFloat(byte[] bytes)
Converts a byte array to a float.
|
static int |
toInt(byte[] bytes)
Converts a byte array to an integer.
|
static long |
toLong(byte[] bytes)
Converts a byte array to a long.
|
static short |
toShort(byte[] bytes)
Converts a byte array to a short.
|
public static byte[] toBytes(long number)
number - the longpublic static long toLong(byte[] bytes)
bytes - the byte arraypublic static byte[] toBytes(int number)
number - the integerpublic static int toInt(byte[] bytes)
bytes - the byte arraypublic static byte[] toBytes(short number)
number - the shortpublic static short toShort(byte[] bytes)
bytes - the byte arraypublic static byte[] toBytes(double number)
number - the doublepublic static double toDouble(byte[] bytes)
bytes - the byte arraypublic static byte[] toBytes(float number)
number - the floatpublic static float toFloat(byte[] bytes)
bytes - the byte arraypublic static byte[] copy(byte[] b)
b - the original byte arraypublic static byte[] copy(byte[] b,
int offset,
int length)
b - the original byte arrayoffset - the initial offsetlength - the lengthpublic static void clear(byte[] b)
b - the byte arraypublic static void clear(char[] c)
c - the char array