The list of methods to do Hex Dump are organized into topic(s).
String
hexDump(byte[] data) Dumps binary data, presending raw bytes and their character equivalents.
if (data == null) {
return NULL;
} else {
StringWriter w = new StringWriter();
hexDump(0, new PrintWriter(w), data, 0, data.length);
return w.toString();
void
hexDump(InputStream is, OutputStream os) Writes a hex dump representation of input data to the output stream.
int offset = 0;
ByteArrayOutputStream hexStream;
ByteArrayOutputStream asciiStream;
while (true) {
hexStream = new ByteArrayOutputStream();
asciiStream = new ByteArrayOutputStream();
int count = getHexSegment(is, hexStream, asciiStream);
if (count <= 0)
...
void
hexDump(String prompt, byte[] bs) hex Dump
PrintStream ps = new PrintStream(new BufferedOutputStream(System.out, 2048));
ps.printf("%s:", prompt);
for (byte b : bs)
ps.printf("%02x ", b);
ps.printf("[");
for (byte b : bs)
ps.printf("%c", Character.isLetterOrDigit(b) ? b : '.');
ps.printf("]\n");
...
void
hexDumpBytes(PrintStream out, long offset, byte[] bytes) hex Dump Bytes
final int lineWidth = 16;
char[] line = new char[lineWidth * 3];
for (int i = 0; i < bytes.length; i += lineWidth) {
int len = Math.min(bytes.length - i, 16);
for (int j = 0; j < len; j++) {
int value = bytes[i + j] & 0xFF;
line[j * 3 + 0] = hexArray[value >>> 4];
line[j * 3 + 1] = hexArray[value & 0x0F];
...