|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.squawk.util.StringTokenizer
public class StringTokenizer
StringTokenizer is a class that controls simple linear tokenization of a String. The set of delimiters, which defaults to common whitespace characters, may be specified at creation time or on a per-token basis.
Example usage:
String s = "this is a test"; StringTokenizer st = new StringTokenizer(s); while (st.hasMoreTokens()) { println(st.nextToken()); }Prints the following on the console:
this is a test
Constructor Summary | |
---|---|
StringTokenizer(String str)
Constructs a StringTokenizer on the specified String, using the default delimiter set (which is " \t\n\r"). |
|
StringTokenizer(String str,
String delim)
Constructs a StringTokenizer on the specified String, using the specified delimiter set. |
|
StringTokenizer(String str,
String delim,
boolean returnTokens)
Constructs a StringTokenizer on the specified String, using the specified delimiter set. |
Method Summary | |
---|---|
int |
countTokens()
Returns the next number of tokens in the String using the current deliminter set. |
boolean |
hasMoreElements()
Returns true if the Enumeration has more elements. |
boolean |
hasMoreTokens()
Returns true if more tokens exist. |
Object |
nextElement()
Returns the next element in the Enumeration. |
String |
nextToken()
Returns the next token of the String. |
String |
nextToken(String delim)
Returns the next token, after switching to the new delimiter set. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StringTokenizer(String str)
str
- the Stringpublic StringTokenizer(String str, String delim)
str
- the input Stringdelim
- the delimiter Stringpublic StringTokenizer(String str, String delim, boolean returnTokens)
str
- the input Stringdelim
- the delimiter StringreturnTokens
- returns delimiters as tokens or skip themMethod Detail |
---|
public int countTokens()
public boolean hasMoreElements()
hasMoreElements
in interface Enumeration
true
if and only if this enumeration object
contains at least one more element to provide;
false
otherwise.public boolean hasMoreTokens()
public Object nextElement()
nextElement
in interface Enumeration
NoSuchElementException
- If there are no more elements
in the enumeration.public String nextToken()
NoSuchElementException
- If there are no more
tokens in the String.public String nextToken(String delim)
delim
- the new delimiters
|
SunSPOT API V3.0 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |