Java Reference
In-Depth Information
The
StringTokenizer
class has several methods to control what is con-
sidered a word, whether it should understand numbers or strings spe-
cially, and so on:
public
StringTokenizer(String
str,
String
delim,boolean
re-
turnTokens)
Constructs a
StringTokenizer
on the string
str
, using the char-
acters in
delim
as the delimiter set. The
returnTokens
boolean
determines whether delimiters are returned as tokens or
skipped. If they are returned as tokens, each delimiter char-
acter is returned separately.
public
StringTokenizer(String str, String delim)
Equivalent to
StringTokenizer(str, delim, false)
, meaning that
delimiters are skipped, not returned.
public
StringTokenizer(String str)
Equivalent to
StringTokenizer(str," \t\n\r\f")
, meaning that
the delimiters are the whitespace characters and are skipped.
public boolean
hasMoreTokens()
Returns
true
if more tokens exist.
public String
nextToken()
Returns the next token of the string. If there are no more
tokens, a
NoSuchElementException
is thrown.
public String
nextToken(String delim)
Switches the delimiter set to the characters in
delim
and re-
turns the next token. There is no way to set a new delimiter