All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----java.util.StringTokenizer
StreamTokenizer class. The
StringTokenizer methods do not distinguish among
identifiers, numbers, and quoted strings, nor do they recognize
and skip comments.
The set of delimiters (the characters that separate tokens) may be specified either at creation time or on a per-token basis.
An instance of StringTokenizer behaves in one of two
ways, depending on whether it was created with the
returnTokens flag having the value true
or false:
false, delimiter characters serve to
separate tokens. A token is a maximal sequence of consecutive
characters that are not delimiters.
true, delimiter characters are considered to
be tokens. A token is either one delimiter character, or a maximal
sequence of consecutive characters that are not delimiters.
The following is one example of the use of the tokenizer. The code:
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
println(st.nextToken());
}
prints the following output:
this
is
a
test
nextToken method can be called before it generates an
exception.
hasMoreTokens
method.
nextToken method,
except that its declared return value is Object rather than
String.
method StringTokenizer(str=String, -
delim=String, -
returnTokens=boolean) public
delim argument are the delimiters
for separating tokens.
If the returnTokens flag is true, then
the delimiter characters are also returned as tokens. Each
delimiter is returned as a string of length one. If the flag is
false, the delimiter characters are skipped and only
serve as separators between tokens.
method StringTokenizer(str=String, -
delim=String) public
delim argument are the delimiters
for separating tokens.
method StringTokenizer(str=String) public
"\t\n\r": the space character, the tab
character, the newline character, and the carriage-return character.
method hasMoreTokens() returns boolean public
true if there are more tokens available from this
tokenizer's string; false otherwise.
method nextToken() returns String public
method nextToken(delim=String) returns String public
method hasMoreElements() returns boolean public
hasMoreTokens
method. It exists so that this class can implement the
Enumeration interface.
true if there are more tokens;
false otherwise.
method nextElement() returns Object public
nextToken method,
except that its declared return value is Object rather than
String. It exists so that this class can implement the
Enumeration interface.
method countTokens() returns int public
nextToken method can be called before it generates an
exception.
All Packages Class Hierarchy This Package Previous Next Index