public static String arrayToHexString(byte[] array,int offset,int limit){
  String retVal;
  if (array != null) {
    StringBuffer hexString=new StringBuffer(array.length);
    int hexVal;
    char hexChar;
    int length=Math.min(limit,array.length);
    for (int i=offset; i < length; i++) {
      hexVal=(array[i] & 0xF0) >> 4;
      hexChar=(char)((hexVal > 9) ? ('A' + (hexVal - 10)) : ('0' + hexVal));
      hexString.append(hexChar);
      hexVal=array[i] & 0x0F;
      hexChar=(char)((hexVal > 9) ? ('A' + (hexVal - 10)) : ('0' + hexVal));
      hexString.append(hexChar);
    }
    retVal=hexString.toString();
  }
 else {
    retVal="<null>";
  }
  return retVal;
}

public static String arrayToHexString ( byte [ ] array , int offset , int limit ) { String retVal ; if ( array != null ) { StringBuffer hexString = new StringBuffer ( array . length ) ; int hexVal ; char hexChar ; int length = Math . min ( limit , array . length ) ; for ( int i = offset ; i < length ; i ++ ) { hexVal = ( array [ i ] & 0xF0 ) > > 4 ; hexChar = ( char ) ( ( hexVal > 9 ) ? ( 'A' + ( hexVal - 10 ) ) : ( '0' + hexVal ) ) ; hexString . append ( hexChar ) ; hexVal = array [ i ] & 0x0F ; hexChar = ( char ) ( ( hexVal > 9 ) ? ( 'A' + ( hexVal - 10 ) ) : ( '0' + hexVal ) ) ; hexString . append ( hexChar ) ; } retVal = hexString . toString ( ) ; } else { retVal = "<null>" ; } return retVal ; }
helper method to convert a byte [ ] array ( such as a msgid ) to a hex string
