Java Code Examples for java.io.StringReader.mark()

The following are Jave code examples for showing how to use mark() of the java.io.StringReader class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: tomcat7   File: HttpParser.java   Source Code and License Vote up 6 votes
private static int skipLws(StringReader input, boolean withReset)
        throws IOException {

    if (withReset) {
        input.mark(1);
    }
    int c = input.read();

    while (c == 32 || c == 9 || c == 10 || c == 13) {
        if (withReset) {
            input.mark(1);
        }
        c = input.read();
    }

    if (withReset) {
        input.reset();
    }
    return c;
}
 
Example 2
Project: Telejam   File: HtmlTextParser.java   Source Code and License Vote up 6 votes
private String getTag(StringReader reader) throws IOException, TextParseException {
  StringBuilder builder = new StringBuilder();

  int c;
  reader.mark(1);
  while ((c = reader.read()) != '>' && !Character.isWhitespace(c)) {
    if (c <= 0) {
      throw new TextParseException("Unterminated tag");
    }
    reader.mark(1);
    builder.append((char) c);
  }
  reader.reset();

  return builder.toString();
}
 
Example 3
Project: apache-tomcat-7.0.73-with-comment   File: HttpParser.java   Source Code and License Vote up 6 votes
private static int skipLws(StringReader input, boolean withReset)
        throws IOException {

    if (withReset) {
        input.mark(1);
    }
    int c = input.read();

    while (c == 32 || c == 9 || c == 10 || c == 13) {
        if (withReset) {
            input.mark(1);
        }
        c = input.read();
    }

    if (withReset) {
        input.reset();
    }
    return c;
}
 
Example 4
Project: lazycat   File: HttpParser.java   Source Code and License Vote up 6 votes
private static int skipLws(StringReader input, boolean withReset) throws IOException {

		if (withReset) {
			input.mark(1);
		}
		int c = input.read();

		while (c == 32 || c == 9 || c == 10 || c == 13) {
			if (withReset) {
				input.mark(1);
			}
			c = input.read();
		}

		if (withReset) {
			input.reset();
		}
		return c;
	}
 
Example 5
Project: sirocco   File: FieldSerializer.java   Source Code and License Vote up 5 votes
public static String readString(StringReader rd) throws Exception {
    // if there is an error in encoding, let the base functions throw an exception
    CSList<Character> clist = new CSList<Character>();
    int nextchar = -1;
    boolean stop = false;
    while (!stop)
    {
        if ((nextchar = rd.read()) == -1)
            stop = true;
        else if ((char)nextchar != '|')
            clist.add((char)nextchar);
        else
        {
            // ignore first | and check whether there is another | following
        	// if the next one is | again, then 
        	rd.mark(1);
            if (((nextchar = rd.read()) != -1) && ((char)nextchar == '|'))
            {
                // this was an escaped |, and so read it as such
            	clist.add((char)nextchar);
            }
            else
            {
            	rd.reset(); //return the stolen character
                stop = true;
            }
        }  
    }
     
    return clist.toArray().toString();
}