|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectandyr.jtokeniser.Tokeniser
andyr.jtokeniser.StringTokeniser
public class StringTokeniser
The StringTokeniser class uses a standard StringTokenizer to find each word in the input.
The following is one example of the use of the tokenizer. The code:
StringTokeniser st = new StringTokeniser("the cat sat on the mat");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
prints the following output:
the
sat
on
the
mat
| Field Summary |
|---|
| Fields inherited from class andyr.jtokeniser.Tokeniser |
|---|
currentTokenPosition, tokens |
| Constructor Summary | |
|---|---|
StringTokeniser(java.lang.String input)
Creates a StringTokeniser that tokenises the input. |
|
StringTokeniser(java.lang.String input,
java.lang.String delim)
Creates a StringTokeniser that tokenises the input according the specified delimiter(s). |
|
StringTokeniser(java.lang.String input,
java.lang.String delim,
boolean keepDelim)
Creates a StringTokeniser that tokenises the input according the specified delimiter(s). |
|
| Method Summary |
|---|
| Methods inherited from class andyr.jtokeniser.Tokeniser |
|---|
countTokens, getTokens, hasMoreTokens, nextToken, numberOfTokens |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public StringTokeniser(java.lang.String input,
java.lang.String delim,
boolean keepDelim)
StringTokeniser that tokenises the input according the specified delimiter(s). Each character in delim
is considered a delimiter for separating tokens.
If the returnDelims 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.
Note that if delim is null, this constructor does not throw an
exception. However, trying to invoke other methods on the resulting
StringTokeniser may result in a NullPointerException.
input - a string from which the tokens will be extracted.delim - the delimiterskeepDelim - flag indicating whether to return the delimiters as tokens.
public StringTokeniser(java.lang.String input,
java.lang.String delim)
delim
is considered a delimiter for separating tokens. Delimiter characters themselves will not be treated as tokens.
Note that if delim is null, this constructor does not throw an
exception. However, trying to invoke other methods on the resulting
StringTokeniser may result in a NullPointerException.
input - a string from which the tokens will be extracted.delim - the delimiterspublic StringTokeniser(java.lang.String input)
"\t\n\r\f": the space character, the
tab character, the newline character, the carriage-return character,
and the form-feed character. Delimiter characters themselves will
not be treated as tokens.
input - a string from which the tokens will be extracted.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||