public final class Hex
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static byte[] |
HEX_BYTES
for hex conversion.
|
private static char[] |
HEX_CHARS |
private static org.apache.commons.logging.Log |
LOG |
Modifier | Constructor and Description |
---|---|
private |
Hex() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
decodeBase64(java.lang.String base64Value)
Decode a base64 String.
|
static byte[] |
decodeHex(java.lang.String s)
Decodes a hex String into a byte array.
|
static byte[] |
getBytes(byte b)
Returns the bytes corresponding to the ASCII hex encoding of the given byte.
|
static byte[] |
getBytes(byte[] bytes)
Returns the bytes corresponding to the ASCII hex encoding of the given bytes.
|
static char[] |
getChars(short num)
Returns the characters corresponding to the ASCII hex encoding of the given short.
|
static char[] |
getCharsUTF16BE(java.lang.String text)
Takes the characters in the given string, convert it to bytes in UTF16-BE format
and build a char array that corresponds to the ASCII hex encoding of the resulting
bytes.
|
private static int |
getHighNibble(byte b)
Get the high nibble of the given byte.
|
private static int |
getLowNibble(byte b)
Get the low nibble of the given byte.
|
static java.lang.String |
getString(byte b)
Returns a hex string of the given byte.
|
static java.lang.String |
getString(byte[] bytes)
Returns a hex string of the given byte array.
|
static void |
writeHexByte(byte b,
java.io.OutputStream output)
Writes the given byte as hex value to the given output stream.
|
static void |
writeHexBytes(byte[] bytes,
java.io.OutputStream output)
Writes the given byte array as hex value to the given output stream.
|
private static final org.apache.commons.logging.Log LOG
private static final byte[] HEX_BYTES
private static final char[] HEX_CHARS
public static java.lang.String getString(byte b)
public static java.lang.String getString(byte[] bytes)
public static byte[] getBytes(byte b)
public static byte[] getBytes(byte[] bytes)
public static char[] getChars(short num)
public static char[] getCharsUTF16BE(java.lang.String text)
getCharsUTF16BE("ab") == new char[]{'0','0','6','1','0','0','6','2'}
text
- The string to convertpublic static void writeHexByte(byte b, java.io.OutputStream output) throws java.io.IOException
b
- the byte to be writtenoutput
- the output stream to be written tojava.io.IOException
- exception if anything went wrongpublic static void writeHexBytes(byte[] bytes, java.io.OutputStream output) throws java.io.IOException
bytes
- the byte array to be writtenoutput
- the output stream to be written tojava.io.IOException
- exception if anything went wrongprivate static int getHighNibble(byte b)
b
- the given byteprivate static int getLowNibble(byte b)
b
- the given bytepublic static byte[] decodeBase64(java.lang.String base64Value)
base64Value
- a base64 encoded String.java.lang.IllegalArgumentException
- if this isn't a base64 encoded string.public static byte[] decodeHex(java.lang.String s) throws java.io.IOException
s
- A String with ASCII hex.java.io.IOException