stringtokenizer有两个常用的方法:
1.hasmoreelements()。这个方法和hasmoreelements()方法的用法是一样的,只是stringtokenizer为了实现enumeration接口而实现的方法,从stringtokenizer的声明可以看到:class stringtokenizer implements enumeration。
2.nextelement()。这个方法和nexttoken()方法的用法是一样的,返回此 stringtokenizer 的下一个标记。
stringtokenizer的三个构造方法:
1.stringtokenizer(string str)。默认以” \t\n\r\f”(前有一个空格,引号不是)为分割符。
token1:www
token1:ooobj
token1:com
2.stringtokenizer(string str, string delim)。指定delim为分割符。
token:www
token:ooo
token:j
token:com
**3.stringtokenizer(string str, string delim, boolean returndelims)。**returndelims为true的话则delim分割符也被视为标记。
token2:www
token2:.
token2:ooobj
token2:com