Created
December 10, 2019 09:52
-
-
Save klausbrunner/e91cb6389dae5df154bb09a62508fce2 to your computer and use it in GitHub Desktop.
Java byte array to hexdump. Format similar to default of hexdump(1).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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