Code example for StreamTokenizer

Methods: linenonextTokenpushBack

        return pos;
    private boolean isNumberNext(StreamTokenizer tokenizer) throws IOException {
        int type = tokenizer.nextToken();
        return type == StreamTokenizer.TT_WORD;
     * Parses the next number in the stream. 
     * Numbers with exponents are handled. 
     * @param tokenizer tokenizer over a stream of text in Well-known Text 
     *                  format. The next token must be a number. 
     * @return the next number in the stream 
     * @throws ParseException if the next token is not a valid number 
     * @throws IOException    if an I/O error occurs 
    private double getNextNumber(StreamTokenizer tokenizer) throws IOException,
            ParseException { 
        int type = tokenizer.nextToken();
        switch (type) {
            case StreamTokenizer.TT_WORD: {
                try { 
                    return Double.parseDouble(tokenizer.sval);
                } catch (NumberFormatException ex) {
                    throw new ParseException("Invalid number: " + tokenizer.sval, tokenizer.lineno());
        parseError("number", tokenizer);
Contextual code suggestions in your IDE  Get Codota for Java