Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Java byte array to hexdump. Format similar to default of hexdump(1).
static String hexDump(byte[] bytes) {
Formatter format = new Formatter(new StringBuilder());
for (int j = 0; j < bytes.length; j++) {
if (j % 16 == 0) {
format.format((j > 0 ? "\n" : "") + "%08X ", j);
}
format.format("%02X ", bytes[j]);
}
return format.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.