public static String toHex(byte[] val,int start,int len){
  StringBuilder buf=new StringBuilder();
  for (int i=0; i < len; i++) {
    byte b=val[start + i];
    buf.append(DEC2HEX[(b & 0xf0) >> 4]);
    buf.append(DEC2HEX[b & 0x0f]);
  }
  return buf.toString();
}

public static String toHex ( byte [ ] val , int start , int len ) { StringBuilder buf = new StringBuilder ( ) ; for ( int i = 0 ; i < len ; i ++ ) { byte b = val [ start + i ] ; buf . append ( DEC2HEX [ ( b & 0xf0 ) > > 4 ] ) ; buf . append ( DEC2HEX [ b & 0x0f ] ) ; } return buf . toString ( ) ; }
can be used to encode values that contain invalid xml characters . at sax parser end must be used pair method to get original value .
