Code example for StreamTokenizer

Methods: ordinaryCharquoteCharresetSyntaxslashSlashCommentsslashStarCommentswhitespaceCharswordChars

0
     * 
     * @param r The {@code Reader} that the {@code StreamTokenizer} will read from 
     * @return a newly-created and initialized {@code StreamTokenizer} 
     */ 
    static StreamTokenizer initTokenizer(Reader r) {
        StreamTokenizer st = new StreamTokenizer(r);
 
        // Treat everything we don't specify as "ordinary". 
        st.resetSyntax();
 
        /* The only non-quoted-string words we'll be reading are: 
         * - property names: [._$a-zA-Z0-9] 
         * - type names: [a-zS] 
         * - number literals: [-0-9.eExXA-Za-z]  ('x' for 0xNNN hex literals. "NaN", "Infinity") 
         * - "true" or "false" (case insensitive): [a-zA-Z] 
         */ 
        st.wordChars('0', '9');
        st.wordChars('A', 'Z');
        st.wordChars('a', 'z');
        st.wordChars('_', '_');
        st.wordChars('$', '$');
        st.wordChars('.', '.');
        st.wordChars('-', '-');
        st.wordChars('+', '+');
 
        // Single-character tokens 
        st.ordinaryChar('=');
 
        // Other special characters 
        st.whitespaceChars(' ', ' ');
        st.whitespaceChars('\t', '\t');
        st.whitespaceChars('\n', '\n');
        st.whitespaceChars('\r', '\r');
        st.quoteChar('"');
 
        // Java-style comments 
        st.slashStarComments(true);
        st.slashSlashComments(true);
 
        return st;
    } 
 
 
Connect your IDE to all the code out there  Get Codota for Java