public final class Hex extends Object
Modifier and Type | Method and Description |
---|---|
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(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.
|
static String |
getString(byte b)
Returns a hex string of the given byte.
|
static String |
getString(byte[] bytes)
Returns a hex string of the given byte array.
|
static void |
writeHexByte(byte b,
OutputStream output)
Writes the given byte as hex value to the given output stream.
|
static void |
writeHexBytes(byte[] bytes,
OutputStream output)
Writes the given byte array as hex value to the given output stream.
|
public static String getString(byte b)
public static 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(String text)
getCharsUTF16BE("ab") == new char[]{'0','0','6','1','0','0','6','2'}
text
- The string to convertpublic static void writeHexByte(byte b, OutputStream output) throws IOException
b
- the byte to be writtenoutput
- the output stream to be written toIOException
- exception if anything went wrongpublic static void writeHexBytes(byte[] bytes, OutputStream output) throws IOException
bytes
- the byte array to be writtenoutput
- the output stream to be written toIOException
- exception if anything went wrongCopyright © 2002–2017 The Apache Software Foundation. All rights reserved.