private static String toHexString ( byte [ ] bytes ) { if ( bytes . length == 0 ) { return "(empty)" ; } StringBuilder sb = new StringBuilder ( bytes . length * 3 - 1 ) ; boolean isInitial = true ; for ( byte b : bytes ) { if ( isInitial ) { isInitial = false ; } else { sb . append ( ' ' ) ; } int k = b & 0xFF ; sb . append ( HEXES [ k >>> 4 ] ) ; sb . append ( HEXES [ k & 0xF ] ) ; } return sb . toString ( ) ; }
convert byte array to hex string