static String scanString(StdXMLReader reader, char entityChar, IXMLEntityResolver entityResolver) throws IOException, XMLParseException {
    StringBuilder result = new StringBuilder();
    int startingLevel = reader.getStreamLevel();
    char delim = reader.read();

    if ((delim != '\'') && (delim != '"')) {
      errorExpectedInput(reader.getSystemID(), reader.getLineNr(), "delimited string");
    }

    for (; ; ) {
      String str = read(reader, entityChar);
      char ch = str.charAt(0);

      if (ch == entityChar) {
        if (str.charAt(1) == '#') {
          result.append(processCharLiteral(str));
        }
        else {
          processEntity(str, reader, entityResolver);
        }
      }
      else if (ch == '&') {
        reader.unread(ch);
        str = read(reader, '&');
        if (str.charAt(1) == '#') {
          result.append(processCharLiteral(str));
        }
        else {
          result.append(str);
        }
      }
      else if (reader.getStreamLevel() == startingLevel) {
        if (ch == delim) {
          break;
        }
        else if ((ch == 9) || (ch == 10) || (ch == 13)) {
          result.append(' ');
        }
        else {
          result.append(ch);
        }
      }
      else {
        result.append(ch);
      }
    }

    return result.toString();
  }
static String scanString(StdXMLReader reader, char entityChar, IXMLEntityResolver entityResolver)