public static String toHexString ( byte [ ] data ) { StringBuilder sb = new StringBuilder ( data . length * 2 ) ; for ( byte element : data ) { sb . append ( Integer . toHexString ( ( element >> 4 ) & 15 ) ) ; sb . append ( Integer . toHexString ( element & 15 ) ) ; } return sb . toString ( ) ; }
Turn a bytearray into a printable form representing each byte in hex .