GeezerVison is showing docs.oracle.com — StreamTokenizer (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.io
Class StreamTokenizer
-
-
Field Summary
Fields
| Modifier and Type |
Field |
Description |
double |
nval |
If the current token is a number, this field contains the value
of that number.
|
String |
sval |
If the current token is a word token, this field contains a
string giving the characters of the word token.
|
static int |
TT_EOF |
A constant indicating that the end of the stream has been read.
|
static int |
TT_EOL |
A constant indicating that the end of the line has been read.
|
static int |
TT_NUMBER |
A constant indicating that a number token has been read.
|
static int |
TT_WORD |
A constant indicating that a word token has been read.
|
int |
ttype |
After a call to the nextToken method, this field
contains the type of the token just read.
|
-
Constructor Summary
Constructors
| Constructor |
Description |
StreamTokenizer(InputStream is) |
Deprecated.
As of JDK version 1.1, the preferred way to tokenize an
input stream is to convert it into a character stream, for example:
Reader r = new BufferedReader(new InputStreamReader(is));
StreamTokenizer st = new StreamTokenizer(r);
|
StreamTokenizer(Reader r) |
Create a tokenizer that parses the given character stream.
|
-
Method Summary
All Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
void |
commentChar(int ch) |
Specified that the character argument starts a single-line
comment.
|
void |
eolIsSignificant(boolean flag) |
Determines whether or not ends of line are treated as tokens.
|
int |
lineno() |
Return the current line number.
|
void |
lowerCaseMode(boolean fl) |
Determines whether or not word token are automatically lowercased.
|
int |
nextToken() |
Parses the next token from the input stream of this tokenizer.
|
void |
ordinaryChar(int ch) |
Specifies that the character argument is "ordinary"
in this tokenizer.
|
void |
ordinaryChars(int low,
int hi) |
Specifies that all characters c in the range
low <= c <= high
are "ordinary" in this tokenizer.
|
void |
parseNumbers() |
Specifies that numbers should be parsed by this tokenizer.
|
void |
pushBack() |
Causes the next call to the nextToken method of this
tokenizer to return the current value in the ttype
field, and not to modify the value in the nval or
sval field.
|
void |
quoteChar(int ch) |
Specifies that matching pairs of this character delimit string
constants in this tokenizer.
|
void |
resetSyntax() |
Resets this tokenizer's syntax table so that all characters are
"ordinary." See the ordinaryChar method
for more information on a character being ordinary.
|
void |
slashSlashComments(boolean flag) |
Determines whether or not the tokenizer recognizes C++-style comments.
|
void |
slashStarComments(boolean flag) |
Determines whether or not the tokenizer recognizes C-style comments.
|
String |
toString() |
Returns the string representation of the current stream token and
the line number it occurs on.
|
void |
whitespaceChars(int low,
int hi) |
Specifies that all characters c in the range
low <= c <= high
are white space characters.
|
void |
wordChars(int low,
int hi) |
Specifies that all characters c in the range
low <= c <= high
are word constituents.
|
-
-
Field Detail
-
ttype
public int ttype
After a call to the nextToken method, this field
contains the type of the token just read. For a single character
token, its value is the single character, converted to an integer.
For a quoted string token, its value is the quote character.
Otherwise, its value is one of the following:
TT_WORD indicates that the token is a word.
TT_NUMBER indicates that the token is a number.
TT_EOL indicates that the end of line has been read.
The field can only have this value if the
eolIsSignificant method has been called with the
argument true.
TT_EOF indicates that the end of the input stream
has been reached.
The initial value of this field is -4.
- See Also:
eolIsSignificant(boolean),
nextToken(),
quoteChar(int),
TT_EOF,
TT_EOL,
TT_NUMBER,
TT_WORD
-
sval
public String sval
If the current token is a word token, this field contains a
string giving the characters of the word token. When the current
token is a quoted string token, this field contains the body of
the string.
The current token is a word when the value of the
ttype field is TT_WORD. The current token is
a quoted string token when the value of the ttype field is
a quote character.
The initial value of this field is null.
- See Also:
quoteChar(int),
TT_WORD,
ttype
-
nval
public double nval
If the current token is a number, this field contains the value
of that number. The current token is a number when the value of
the ttype field is TT_NUMBER.
The initial value of this field is 0.0.
- See Also:
TT_NUMBER,
ttype
-
Method Detail
-
wordChars
public void wordChars(int low,
int hi)
Specifies that all characters c in the range
low <= c <= high
are word constituents. A word token consists of a word constituent
followed by zero or more word constituents or number constituents.
- Parameters:
low - the low end of the range.
hi - the high end of the range.
-
ordinaryChars
public void ordinaryChars(int low,
int hi)
Specifies that all characters c in the range
low <= c <= high
are "ordinary" in this tokenizer. See the
ordinaryChar method for more information on a
character being ordinary.
- Parameters:
low - the low end of the range.
hi - the high end of the range.
- See Also:
ordinaryChar(int)
-
toString
public String toString()
Returns the string representation of the current stream token and
the line number it occurs on.
The precise string returned is unspecified, although the following
example can be considered typical:
Token['a'], line 10
- Overrides:
toString in class Object
- Returns:
- a string representation of the token
- See Also:
nval,
sval,
ttype
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|