public static String toHexString(byte[] bytes){
  return String.format(Locale.US,"%0" + (bytes.length << 1) + "x",new BigInteger(1,bytes));
}

public static String toHexString ( byte [ ] bytes ) { return String . format ( Locale . US , "%0" + ( bytes . length << 1 ) + "x" , new BigInteger ( 1 , bytes ) ) ; }
converts the given bytes to a hexidecimal strings including leading zeros . if you do not need leading zeros , you can use java ' s tostring ( 16 ) instead .
