public static String bytesToHexString(byte[] bytes){
  StringBuffer buf=new StringBuffer(bytes.length * 2);
  for (  byte b : bytes) {
    String s=Integer.toString(0xFF & b,16);
    if (s.length() < 2)     buf.append('0');
    buf.append(s);
  }
  return buf.toString();
}

public static String bytesToHexString ( byte [ ] bytes ) { StringBuffer buf = new StringBuffer ( bytes . length * 2 ) ; for ( byte b : bytes ) { String s = Integer . toString ( 0xFF & b , 16 ) ; if ( s . length ( ) < 2 ) buf . append ( '0' ) ; buf . append ( s ) ; } return buf . toString ( ) ; }
returns the given byte array hex encoded .
