DthingApi
|
Public Member Functions | |
StringTokenizer (String string) | |
StringTokenizer (String string, String delimiters) | |
StringTokenizer (String string, String delimiters, boolean returnDelimiters) | |
int | countTokens () |
boolean | hasMoreElements () |
boolean | hasMoreTokens () |
Object | nextElement () |
String | nextToken () |
String | nextToken (String delims) |
![]() | |
boolean | hasMoreElements () |
E | nextElement () |
The
class allows an application to break a string into tokens by performing code point comparison. The
methods do not distinguish among identifiers, numbers, and quoted strings, nor do they recognize and skip comments.
The set of delimiters (the codepoints that separate tokens) may be specified either at creation time or on a per-token basis.
An instance of
behaves in one of three ways, depending on whether it was created with the
flag having the value
or
:
A token is thus either one delimiter code point, or a maximal sequence of consecutive code points that are not delimiters.
A
object internally maintains a current position within the string to be tokenized. Some operations advance this current position past the code point processed.
A token is returned by taking a substring of the string that was used to create the
object.
Here's an example of the use of the default delimiter
:
StringTokenizer st = new StringTokenizer("this is a test"); while (st.hasMoreTokens()) { println(st.nextToken()); }
This prints the following output:
this is a test
Here's an example of how to use a
with a user specified delimiter:
StringTokenizer st = new StringTokenizer( "this is a test with supplementary characters ", " "); while (st.hasMoreTokens()) { println(st.nextToken()); }
This prints the following output:
this is a test with supplementary characters
|
inline |
Constructs a new
for the parameter string using whitespace as the delimiter. The
flag is set to
.
string | the string to be tokenized. |
|
inline |
Constructs a new
for the parameter string using the specified delimiters. The
flag is set to
. If
is
, this constructor doesn't throw an
, but later calls to some methods might throw a
.
string | the string to be tokenized. |
delimiters | the delimiters to use. |
|
inline |
Constructs a new
for the parameter string using the specified delimiters, returning the delimiters as tokens if the parameter
is
. If
is null this constructor doesn't throw an
, but later calls to some methods might throw a
.
string | the string to be tokenized. |
delimiters | the delimiters to use. |
returnDelimiters | true |
|
inline |
Returns the number of unprocessed tokens remaining in the string.
|
inline |
Returns
if unprocessed tokens remain. This method is implemented in order to satisfy the
interface.
|
inline |
Returns
if unprocessed tokens remain.
|
inline |
Returns the next token in the string as an
. This method is implemented in order to satisfy the
interface.
NoSuchElementException | if no tokens remain. |
|
inline |
Returns the next token in the string as a
.
NoSuchElementException | if no tokens remain. |
|
inline |
Returns the next token in the string as a
. The delimiters used are changed to the specified delimiters.
delims | the new delimiters to use. |
NoSuchElementException | if no tokens remain. |