Java Reference
In-Depth Information
0: 3
1: 4
2: 1
3: 2
Data from the last unread (the one with '3' and '4' ) is read back first,
and within that unread the data comes from the beginning of the array
through to the end. When that data is exhausted, the data from the first
unread is returned in the same order. The unread method copies data into
the pushback buffer, so changes made to an array after it is used with
unread do not affect future calls to read .
20.5.12. StreamTokenizer
Tokenizing input text is a common application, and the java.io package
provides a StreamTokenizer class for simple tokenization. A more general
facility for scanning and converting input text is provided by the
java.util.Scanner classsee " Scanner " on page 641 .
You can tokenize a stream by creating a StreamTokenizer with a Reader
object as its source and then setting parameters for the scan. A scanner
loop invokes nextToken , which returns the token type of the next token
in the stream. Some token types have associated values that are found
in fields in the StreamTokenizer object.
This class is designed primarily to parse programming language-style
input; it is not a general tokenizer. However, many configuration files
look similar enough to programming languages that they can be parsed
by this tokenizer. When designing a new configuration file or other data,
you can save work if you make it look enough like a language to be
parsed with StreamTokenizer .
When nextToken recognizes a token, it returns the token type as its value
and also sets the ttype field to the same value. There are four token
types:
 
Search WWH ::




Custom Search