Java 8 StreamTokenizer - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 StreamTokenizer class.

This code example shows how to use the following methods:ordinaryChar
public class ExpressionParser { 
 
	private final StreamTokenizer tokenizer;
 
	public ExpressionParser(final String s) throws IOException {
		tokenizer = new StreamTokenizer(new StringReader(s));
		tokenizer.ordinaryChar('(');
		tokenizer.ordinaryChar(')');
		tokenizer.ordinaryChar('+');
		tokenizer.ordinaryChar('-');
		tokenizer.ordinaryChar('*');
		tokenizer.ordinaryChar('/');
	} 
 
	public IExpression parse() throws IOException {
		tokenizer.nextToken();
		final IExpression e = term();
		expect(TT_EOF);
		return e;
	} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:lineno, nextToken, pushBack
public class LispTokenizer implements Iterator<Token>
{ 
    // Instance variables have default access to allow unit tests access. 
    StreamTokenizer m_tokenizer;
    IOException m_ioexn;
 
    /** Constructs a tokenizer that scans input from the given string. 
     * @param src A string containing S-expressions. 
     */ 
    public LispTokenizer(String src)
    { 
        this(new StringReader(src));
    } 
 
    /** Constructs a tokenizer that scans input from the given Reader. 
     * @param r Reader for the character input source 
     */ 
    public LispTokenizer(Reader r)
    { 
        if(r == null)

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:nextToken, toString
     * An unchecked exception that is thrown when encountering a syntax 
     * or semantic error in the input. 
     */ 
    public static class ParseException extends IllegalArgumentException {
        ParseException(StreamTokenizer state, String expected) {
            super("expected " + expected + ", saw " + state.toString());
        } 
    } 
 
    // A sentinel instance used to indicate a null string. 
    static final String NULL_STRING = new String("<TypedProperties:NULL_STRING>");
 
    // Constants used to represent the supported types. 
    static final int TYPE_UNSET = 'x';
    static final int TYPE_BOOLEAN = 'Z';
    static final int TYPE_BYTE = 'I' | 1 << 8;
    // TYPE_CHAR: character literal syntax not supported; use short. 
    static final int TYPE_SHORT = 'I' | 2 << 8;
    static final int TYPE_INT = 'I' | 4 << 8;
    static final int TYPE_LONG = 'I' | 8 << 8;

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:commentChar, eolIsSignificant, lowerCaseMode, nextToken, ordinaryChar
        String str = "Testing 12345 \n alpha \r\n omega";
        String strb = "-3.8 'BLIND mice' \r sEe /* how */ they run";
        StringReader aa = new StringReader(str);
        StringReader ba = new StringReader(strb);
        StreamTokenizer a = new StreamTokenizer(aa);
        StreamTokenizer b = new StreamTokenizer(ba);
 
        assertEquals(1, a.lineno());
        assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
        assertEquals("Token[Testing], line 1", a.toString());
        assertEquals(StreamTokenizer.TT_NUMBER, a.nextToken());
        assertEquals("Token[n=12345.0], line 1", a.toString());
        assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
        assertEquals("Token[alpha], line 2", a.toString());
        assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
        assertEquals("Token[omega], line 3", a.toString());
        assertEquals(StreamTokenizer.TT_EOF, a.nextToken());
        assertEquals("Token[EOF], line 3", a.toString());
 
        b.commentChar('u');

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:eolIsSignificant, resetSyntax, whitespaceChars, wordChars
     * Scans the file for coefficients 
     */ 
    private void scan(File coeffFile) throws FileNotFoundException,
            IOException { 
        FileReader reader = new FileReader(coeffFile);
        StreamTokenizer tokenizer = new StreamTokenizer(reader);
 
        tokenizer.resetSyntax();
        tokenizer.whitespaceChars(0, 32);
        tokenizer.eolIsSignificant(false);
        tokenizer.wordChars(33, 255);
 
        _ah2o = getNextCoefficient(tokenizer);
        _nh2o = getNextCoefficient(tokenizer);
        _ao3 = getNextCoefficient(tokenizer);
        _no3 = getNextCoefficient(tokenizer);
        _ao2 = getNextCoefficient(tokenizer);
        _no2 = getNextCoefficient(tokenizer);
        _po2 = getNextCoefficient(tokenizer);
        _aco2 = getNextCoefficient(tokenizer);

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:eolIsSignificant, nextToken, ordinaryChar
		assertTrue("Wrong token 1,3", s.nextToken() == '\n');
		assertTrue("Wrong token 1,4", s.nextToken() == '\n');
		pout.close();
		assertTrue("Wrong token 1,5",
			   s.nextToken() == StreamTokenizer.TT_EOF);
		StreamTokenizer tokenizer = new StreamTokenizer(
								new Support_StringReader("\n \r\n#")); 
		tokenizer.ordinaryChar('\n'); // make \n ordinary
		tokenizer.eolIsSignificant(true);
		assertTrue("Wrong token 2,1", tokenizer.nextToken() == '\n');
		assertTrue("Wrong token 2,2", tokenizer.nextToken() == '\n');
		assertEquals("Wrong token 2,3", '#', tokenizer.nextToken());
	} 
 
	/** 
	 * @tests java.io.StreamTokenizer#ordinaryChar(int) 
	 */ 
	public void test_ordinaryCharI() throws IOException { 
		// SM. 
		setTest("Ffjein 893"); 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:lineno, nextToken
            case '"': 
                try { 
                    weight = Float.parseFloat(tokens.sval);
                } catch (NumberFormatException e) {
                    throw new ConfigFormatException("illegal weight value \"" + 
                            tokens.sval + "\" on line " + tokens.lineno());
                } 
                tokens.nextToken();
                return weight;
 
            default: 
                throw new ConfigFormatException("missing weight value on line " 
                        + tokens.lineno());
        } 
    } 
 
    String parseBenchName(StreamTokenizer tokens)
        throws IOException, ConfigFormatException 
    { 
        String name;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toString
     * An unchecked exception that is thrown when encountering a syntax 
     * or semantic error in the input. 
     */ 
    public static class ParseException extends IllegalArgumentException {
        ParseException(StreamTokenizer state, String expected) {
            super("expected " + expected + ", saw " + state.toString());
        } 
    } 
 
    // A sentinel instance used to indicate a null string. 
    static final String NULL_STRING = new String("<TypedProperties:NULL_STRING>");
 
    // Constants used to represent the supported types. 
    static final int TYPE_UNSET = 'x';
    static final int TYPE_BOOLEAN = 'Z';
    static final int TYPE_BYTE = 'I' | 1 << 8;
    // TYPE_CHAR: character literal syntax not supported; use short. 
    static final int TYPE_SHORT = 'I' | 2 << 8;
    static final int TYPE_INT = 'I' | 4 << 8;
    static final int TYPE_LONG = 'I' | 8 << 8;
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:eolIsSignificant, ordinaryChar, quoteChar, resetSyntax, whitespaceChars
      this(reader, totalNumFields, true);
   } 
 
   public CsvReader(Reader reader, int totalNumFields, boolean enabled) throws IOException {
      this.reader = reader;
      this.streamTokenizer = new StreamTokenizer(reader);
      this.fieldsUsed = new boolean[totalNumFields];
      Arrays.fill(fieldsUsed, enabled);
      countFieldsUsed(); 
 
      streamTokenizer.resetSyntax();
      streamTokenizer.eolIsSignificant(true);
      streamTokenizer.whitespaceChars(0, ' ' - 1);
      streamTokenizer.wordChars(' ', 255); // make all non-white space characters part of the returned string
      streamTokenizer.ordinaryChar(','); // except the delimiter ','
      streamTokenizer.quoteChar('\"'); // and the quote char
 
      getRow(); //prime so hasNext might return true (and getRow will return the first row the next time it is called) 
   } 
 
   private void countFieldsUsed() { 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:commentChar, eolIsSignificant, lowerCaseMode, nextToken, ordinaryChar
        String str = "Testing 12345 \n alpha \r\n omega";
        String strb = "-3.8 'BLIND mice' \r sEe /* how */ they run";
        StringReader aa = new StringReader(str);
        StringReader ba = new StringReader(strb);
        StreamTokenizer a = new StreamTokenizer(aa);
        StreamTokenizer b = new StreamTokenizer(ba);
 
        assertEquals(1, a.lineno());
        assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
        assertEquals("Token[Testing], line 1", a.toString());
        assertEquals(StreamTokenizer.TT_NUMBER, a.nextToken());
        assertEquals("Token[n=12345.0], line 1", a.toString());
        assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
        assertEquals("Token[alpha], line 2", a.toString());
        assertEquals(StreamTokenizer.TT_WORD, a.nextToken());
        assertEquals("Token[omega], line 3", a.toString());
        assertEquals(StreamTokenizer.TT_EOF, a.nextToken());
        assertEquals("Token[EOF], line 3", a.toString());
 
        b.commentChar('u');

6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 StreamTokenizer Methods: