public class HexUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
static char[] |
HEX_TABLE |
| Constructor and Description |
|---|
HexUtil() |
| Modifier and Type | Method and Description |
|---|---|
static void |
appendHexString(StringBuilder buffer,
byte value)
Appends 2 characters to a StringBuilder with the byte in a "Big Endian"
hexidecimal format.
|
static void |
appendHexString(StringBuilder buffer,
byte[] bytes)
Appends a byte array to a StringBuilder with each byte in a "Big Endian"
hexidecimal format.
|
static void |
appendHexString(StringBuilder buffer,
byte[] bytes,
int offset,
int length)
Appends a byte array to a StringBuilder with each byte in a "Big Endian"
hexidecimal format.
|
static void |
appendHexString(StringBuilder buffer,
int value)
Appends 8 characters to a StringBuilder with the int in a "Big Endian"
hexidecimal format.
|
static void |
appendHexString(StringBuilder buffer,
long value)
Appends 16 characters to a StringBuilder with the long in a "Big Endian"
hexidecimal format.
|
static void |
appendHexString(StringBuilder buffer,
short value)
Appends 4 characters to a StringBuilder with the short in a "Big Endian"
hexidecimal format.
|
static int |
hexCharToIntValue(char c)
Converts a hexidecimal character such as '0' or 'A' or 'a' to its integer
value such as 0 or 10.
|
static byte[] |
toByteArray(CharSequence hexString)
Creates a byte array from a CharSequence (String, StringBuilder, etc.)
containing only valid hexidecimal formatted characters.
|
static byte[] |
toByteArray(CharSequence hexString,
int offset,
int length)
Creates a byte array from a CharSequence (String, StringBuilder, etc.)
containing only valid hexidecimal formatted characters.
|
static String |
toHexString(byte value)
Creates a 2 character hex String from a byte with the byte in a "Big Endian"
hexidecimal format.
|
static String |
toHexString(byte[] bytes)
Creates a String from a byte array with each byte in a "Big Endian"
hexidecimal format.
|
static String |
toHexString(byte[] bytes,
int offset,
int length)
Creates a String from a byte array with each byte in a "Big Endian"
hexidecimal format.
|
static String |
toHexString(int value)
Creates an 8 character hex String from an int twith the int in a "Big Endian"
hexidecimal format.
|
static String |
toHexString(long value)
Creates a 16 character hex String from a long with the long in a "Big Endian"
hexidecimal format.
|
static String |
toHexString(short value)
Creates a 4 character hex String from a short with the short in a "Big Endian"
hexidecimal format.
|
public static String toHexString(byte[] bytes)
buffer - The StringBuilder the byte array in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.bytes - The byte array that will be converted to a hexidecimal String.
If the byte array is null, this method will append nothing (a noop)public static String toHexString(byte[] bytes, int offset, int length)
buffer - The StringBuilder the byte array in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.bytes - The byte array that will be converted to a hexidecimal String.
If the byte array is null, this method will append nothing (a noop)offset - The offset in the byte array to start from. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.length - The length (from the offset) to conver the bytes. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.public static void appendHexString(StringBuilder buffer, byte[] bytes)
buffer - The StringBuilder the byte array in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.bytes - The byte array that will be converted to a hexidecimal String.
If the byte array is null, this method will append nothing (a noop)public static void appendHexString(StringBuilder buffer, byte[] bytes, int offset, int length)
buffer - The StringBuilder the byte array in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.bytes - The byte array that will be converted to a hexidecimal String.
If the byte array is null, this method will append nothing (a noop)offset - The offset in the byte array to start from. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.length - The length (from the offset) to conver the bytes. If the offset
or length combination is invalid, this method will throw an IllegalArgumentException.public static String toHexString(byte value)
value - The byte value that will be converted to a hexidecimal String.public static void appendHexString(StringBuilder buffer, byte value)
buffer - The StringBuilder the byte value in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.value - The byte value that will be converted to a hexidecimal String.public static String toHexString(short value)
value - The short value that will be converted to a hexidecimal String.public static void appendHexString(StringBuilder buffer, short value)
buffer - The StringBuilder the short value in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.value - The short value that will be converted to a hexidecimal String.public static String toHexString(int value)
value - The int value that will be converted to a hexidecimal String.public static void appendHexString(StringBuilder buffer, int value)
buffer - The StringBuilder the int value in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.value - The int value that will be converted to a hexidecimal String.public static String toHexString(long value)
value - The long value that will be converted to a hexidecimal String.public static void appendHexString(StringBuilder buffer, long value)
buffer - The StringBuilder the long value in hexidecimal format
will be appended to. If the buffer is null, this method will throw
a NullPointerException.value - The long value that will be converted to a hexidecimal String.public static int hexCharToIntValue(char c)
c - The hexidecimal characterIllegalArgumentException - Thrown if a character that does not
represent a hexidecimal character is used.public static byte[] toByteArray(CharSequence hexString)
hexString - The String, StringBuilder, etc. that contains the
sequence of hexidecimal character values.public static byte[] toByteArray(CharSequence hexString, int offset, int length)
hexString - The String, StringBuilder, etc. that contains the
sequence of hexidecimal character values.offset - The offset within the sequence to start from. If the offset
is invalid, will cause an IllegalArgumentException.length - The length from the offset to convert. If the length
is invalid, will cause an IllegalArgumentException.Copyright © 2012-2015 Cloudhopper by Twitter. All Rights Reserved.