@Override
  public int read(char[] outputBuffer, int offset, int size) throws IOException {
    try {
      int charsRead = 0;
      int bufferLength = buffer.length();

      if ((offset + size) > outputBuffer.length) {
        size = outputBuffer.length - offset;
      }

      while (charsRead < size) {
        String str;
        char ch;

        if (bufferIndex >= bufferLength) {
          str = XMLUtil.read(reader, '&');
          ch = str.charAt(0);
        }
        else {
          ch = buffer.charAt(bufferIndex);
          bufferIndex++;
          outputBuffer[charsRead] = ch;
          charsRead++;
          continue; // don't interpret chars in the buffer
        }

        if (ch == '<') {
          reader.unread(ch);
          break;
        }

        if ((ch == '&') && (str.length() > 1)) {
          if (str.charAt(1) == '#') {
            ch = XMLUtil.processCharLiteral(str);
          }
          else {
            XMLUtil.processEntity(str, reader, resolver);
            continue;
          }
        }

        outputBuffer[charsRead] = ch;
        charsRead++;
      }

      if (charsRead == 0) {
        charsRead = -1;
      }

      return charsRead;
    }
    catch (XMLParseException e) {
      throw new IOException(e.getMessage());
    }
  }
@Override
  public int read(char[] outputBuffer, int offset, int size)