- test code
StringTokenizer st = new String("this is a test");
while(st.hasMoreTokens()){
System.out.println(st.nextToken());
}- ouput
this
is
a
test-
Constructors
- StringTokenizer(String str)
- StringTokenizer(string str, string delim)
- 특정 delim으로 문자열 분리
- StringTokenizer(String str, String delim, boolean returnDelims)
-
Method Summary
| Modifer and Type | Method and Description |
|---|---|
| int | countTokens() 남아있는 token의 개수 반환 전체 token이 아닌 현재 남아있는 token의 갯수 |
| boolean | hasMoreElements() 남아있는 token이 있으면 true반환 |
| boolean | hasMoreTokens() hasMoreElements() 와 같음 |
| objects | nextElement() 다음 토큰을 반환 (object로 반환) |
| string | nextToken() 다음 토큰을 반환 |
| string | nextToken(String delim) delim 기준으로 다음 토큰 반환 |
https://docs.oracle.com/javase/7/docs/api/java/util/StringTokenizer.html