public class Hex extends Object
| Constructor and Description |
|---|
Hex() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
toByte(String hexString)
Decodes a hexadecimal string into a byte array.
|
static String |
toHex(byte value)
Formats the given byte as a 2-digit hexadecimal value.
|
static String |
toHex(byte[] buffer)
Converts the given buffer to a hexadecimal string.
|
static String |
toHex(byte[] buffer,
boolean upperCase)
Converts the given buffer to a hexadecimal string, using upper-case
characters for the digits ‘a’ to ‘f’, if desired.
|
static String |
toHex(byte[] buffer,
int start,
int length)
Converts
length bytes of the given buffer starting at index
start to a hexadecimal string. |
static String |
toHex(byte[] buffer,
int start,
int length,
boolean upperCase)
Converts
length bytes of the given buffer starting at index
start to a hexadecimal string, using upper-case characters
for the digits ‘a’ to ‘f’, if desired. |
static String |
toHex(int value)
Formats the given int as a 8-digit hexadecimal value.
|
static String |
toHex(long value)
Formats the given int as a 16-digit hexadecimal value.
|
static String |
toHex(long value,
int digits)
Formats the given value with as a hexadecimal number with at least the
specified number of digits.
|
static String |
toHex(short value)
Formats the given shoirt as a 4-digit hexadecimal value.
|
static String |
toHex(String buffer)
Converts the given string to a hexadecimal string.
|
static String |
toHex(String buffer,
boolean upperCase)
Converts the given string to a hexadecimal string, using upper-case
characters for the digits ‘a’ to ‘f’, if desired.
|
public static String toHex(String buffer)
buffer - The string to converttoHex(byte[], int, int)public static String toHex(byte[] buffer)
buffer - The buffer to converttoHex(byte[], int, int)public static String toHex(byte[] buffer, int start, int length)
length bytes of the given buffer starting at index
start to a hexadecimal string.buffer - The buffer to convertstart - The index to startlength - The length to convertArrayIndexOutOfBoundsException - if start and/or start + length are
outside the valid bounds of buffertoHex(byte[], int, int)public static String toHex(String buffer, boolean upperCase)
buffer - The string to convertupperCase - if the digits 'a' to 'f' should be in upper-case characterstoHex(byte[], int, int, boolean)public static String toHex(byte[] buffer, boolean upperCase)
buffer - The buffer to convertupperCase - if the digits 'a' to 'f' should be in upper-case characterstoHex(byte[], int, int)public static String toHex(byte[] buffer, int start, int length, boolean upperCase)
length bytes of the given buffer starting at index
start to a hexadecimal string, using upper-case characters
for the digits ‘a’ to ‘f’, if desired.buffer - The buffer to convertstart - The index to startlength - The length to convertupperCase - if the digits 'a' to 'f' should be in upper-case charactersArrayIndexOutOfBoundsException - if start and/or start + length are
outside the valid bounds of buffertoHex(byte[], int, int)public static String toHex(byte value)
value - The byte to encodepublic static String toHex(short value)
value - The short to encodepublic static String toHex(int value)
value - The int to encodepublic static String toHex(long value)
value - The long to encodepublic static String toHex(long value, int digits)
digits.value - The value to encodedigits - The minimum number of digitspublic static byte[] toByte(String hexString)
hexString - The hexadecimal representation to decodeInteger.parseInt(java.lang.String, int)Copyright © 2026. All rights reserved.