public class ByteUtil extends Object
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
array(int length,
byte value)
Get a new array with a specific length and filled with a byte value.
|
static byte[] |
concat(byte[] bytes1,
byte[] bytes2)
Concatenates two byte arrays.
|
static byte[] |
copy(byte[] bytes)
Copy an entire array.
|
static byte[] |
copy(byte[] bytes,
int start,
int end)
Copy part of an array.
|
static boolean |
equalArrays(byte[] bytes1,
byte[] bytes2)
Check if two arrays of bytes are equal.
|
static int |
fromHexChar(char chr)
Get a number value from a hexadecimal char.
|
static byte[] |
replace(byte[] bytes,
byte[] replacement,
int index)
Replace part of an array of bytes with another subarray of bytes and
starting from a given index.
|
static byte[] |
toBytes(long number)
Get an array of bytes from a given number.
|
static byte[] |
toBytes(String hexadecimal)
Get an array of bytes from a given hexadecimal string.
|
static String |
toHexadecimal(byte[] bytes)
Get a hexadecimal string from given array of bytes.
|
static String |
toHexadecimal(long number)
Get a hexadecimal string from given number.
|
static char |
toHexChar(int number)
Get a hexadecimal from a number value.
|
static long |
toNumber(byte[] bytes)
Get a number from a given array of bytes.
|
static long |
toNumber(byte[] bytes,
int start,
int end) |
static long |
toNumber(String hexadecimal)
Get a number from a given hexadecimal string.
|
public static long toNumber(String hexadecimal)
hexadecimal - a stringpublic static long toNumber(byte[] bytes)
bytes - a byte arraypublic static long toNumber(byte[] bytes,
int start,
int end)
public static byte[] toBytes(long number)
number - a long valuepublic static byte[] toBytes(String hexadecimal)
hexadecimal - a stringpublic static String toHexadecimal(byte[] bytes)
bytes - byte arraypublic static String toHexadecimal(long number)
number - an integerpublic static int fromHexChar(char chr)
chr - a characterpublic static char toHexChar(int number)
number - an integerpublic static byte[] array(int length,
byte value)
length - array sizevalue - byte valuepublic static byte[] copy(byte[] bytes)
bytes - byte arraypublic static byte[] copy(byte[] bytes,
int start,
int end)
bytes - byte arraystart - start positionend - end positionpublic static byte[] concat(byte[] bytes1,
byte[] bytes2)
bytes1 - byte array 1bytes2 - byte array 2public static byte[] replace(byte[] bytes,
byte[] replacement,
int index)
bytes - byte arrayreplacement - replacement byte arrayindex - start positionpublic static boolean equalArrays(byte[] bytes1,
byte[] bytes2)
bytes1 - byte array 1bytes2 - byte array 2Copyright © 2019. All rights reserved.