|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jcoderz.commons.util.HexUtil
public final class HexUtil
This class converts byte array data from and to hex and also provides a hexdump method.
| Method Summary | |
|---|---|
static String |
bytesToHex(byte[] data)
Converts a byte array into an upper-case hex string, starting at the first byte and converting the whole array. |
static String |
bytesToHex(byte[] data,
int offset,
int length)
Converts a byte array into an upper-case hex string, starting at the given offset and converting the given number of bytes. |
static String |
dump(byte[] data)
Produces a hexdump of the given byte array with a formatting as in "hexdump -C" (canonical hex + ASCII display). |
static byte[] |
stringToBytes(String s)
Convert the given hex string to a byte array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static String bytesToHex(byte[] data,
int offset,
int length)
throws IndexOutOfBoundsException
data - the byte data to convert to hexoffset - the start offset in the byte arraylength - the number of bytes to convert
IndexOutOfBoundsException - if offset + length > data.lenghtpublic static String bytesToHex(byte[] data)
data - the byte data to convert to hex
public static byte[] stringToBytes(String s)
throws IllegalArgumentException
s - the string to convert
IllegalArgumentException - if the string is not a multiple of 2
characters long, or if the string contains an invalid hex charpublic static String dump(byte[] data)
data - the byte data to dump
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||