Skip to content

Instantly share code, notes, and snippets.

@jpwsutton
Created November 17, 2016 11:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpwsutton/6d0607cc849f480f25d1f51fddecbf4a to your computer and use it in GitHub Desktop.
Save jpwsutton/6d0607cc849f480f25d1f51fddecbf4a to your computer and use it in GitHub Desktop.
Prints a byte array in binary, hex and dec.
private void printByteArray(byte[] bytes){
for (byte b1 : bytes){
String s1 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0');
s1 += " " + Integer.toHexString(b1);
s1 += " " + b1;
System.out.println(s1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment