public static String asHex ( byte [ ] bytes , String separator ) { StringBuilder sb = new StringBuilder ( ) ; for ( int i = 0 ; i < bytes . length ; i ++ ) { String code = Integer . toHexString ( bytes [ i ] & 0xFF ) ; if ( ( bytes [ i ] & 0xFF ) < 16 ) { sb . append ( ' ' ) ; } sb . append ( code ) ; if ( separator != null && i < bytes . length - 1 ) { sb . append ( separator ) ; } } return sb . toString ( ) ; }
Returns a hexadecimal representation of the given byte array .