public static String byteArrayToHexString(byte[] bytes,int pos,int len){
  StringBuilder sb=new StringBuilder(bytes.length * 2);
  Formatter formatter=new Formatter(sb);
  for (int i=pos; i < pos + len; ++i) {
    formatter.format("%02x",bytes[i]);
  }
  return sb.toString();
}

public static String byteArrayToHexString ( byte [ ] bytes , int pos , int len ) { StringBuilder sb = new StringBuilder ( bytes . length * 2 ) ; Formatter formatter = new Formatter ( sb ) ; for ( int i = pos ; i < pos + len ; ++ i ) { formatter . format ( "%02x" , bytes [ i ] ) ; } return sb . toString ( ) ; }
converts a byte array to hex string .
