public static String convertToHexString ( byte [ ] toBeConverted ) { if ( toBeConverted == null ) { throw new NullPointerException ( "Parameter to be converted can not be null" ) ; } char [ ] converted = new char [ toBeConverted . length * 2 ] ; for ( int i = 0 ; i < toBeConverted . length ; i ++ ) { byte b = toBeConverted [ i ] ; converted [ i * 2 ] = HEX_CHARS [ b >> 4 & 0x0F ] ; converted [ i * 2 + 1 ] = HEX_CHARS [ b & 0x0F ] ; } return String . valueOf ( converted ) ; }
Take the supplied byte array and convert it to a hex encoded String .