public static String toHexString(byte[] bytes){
  StringBuilder sb=new StringBuilder();
  if (bytes == null) {
    sb.append("null");
  }
 else {
    for (    byte b : bytes) {
      sb.append(String.format("%02x",b & 0xFF));
    }
  }
  return sb.toString();
}

public static String toHexString ( byte [ ] bytes ) { StringBuilder sb = new StringBuilder ( ) ; if ( bytes == null ) { sb . append ( "null" ) ; } else { for ( byte b : bytes ) { sb . append ( String . format ( "%02x" , b & 0xFF ) ) ; } } return sb . toString ( ) ; }
converts the specified byte array to a hexadecimal string .
