public static String convertToHexString(byte[] bytes){
  int size=bytes.length;
  StringBuffer buffer=new StringBuffer(size * 2);
  for (int i=0; i < size; i++) {
    int x=bytes[i];
    if (x < 0)     x+=256;
    String tmp=Integer.toHexString(x);
    if (tmp.length() == 1)     buffer.append("0");
    buffer.append(tmp);
  }
  return buffer.toString();
}

public static String convertToHexString ( byte [ ] bytes ) { int size = bytes . length ; StringBuffer buffer = new StringBuffer ( size * 2 ) ; for ( int i = 0 ; i < size ; i ++ ) { int x = bytes [ i ] ; if ( x < 0 ) x += 256 ; String tmp = Integer . toHexString ( x ) ; if ( tmp . length ( ) == 1 ) buffer . append ( "0" ) ; buffer . append ( tmp ) ; } return buffer . toString ( ) ; }
convert byte array to hex string
