Code example for StreamTokenizer

Methods: commentCharresetSyntaxslashStarCommentswhitespaceCharswordChars

0
public class CSSParser { 
    public void parse(String css, StyleManager rm) throws IOException {
        parse(new StringReader(css), rm);
    } 
    public void parse(Reader css, StyleManager rm) throws IOException {
        StreamTokenizer tt = new StreamTokenizer(css);
        tt.resetSyntax();
        tt.wordChars('a', 'z');
        tt.wordChars('A', 'Z');
        tt.wordChars('0', '9');
        tt.wordChars(128 + 32, 255);
        tt.whitespaceChars(0, ' ');
        tt.commentChar('/');
        tt.slashStarComments(true);
        parseStylesheet(tt, rm);
    } 
     
    private void parseStylesheet(StreamTokenizer tt, StyleManager rm) throws IOException {
        while (tt.nextToken() != StreamTokenizer.TT_EOF) {
            tt.pushBack();
            parseRuleset(tt, rm);