「Java」java.util.StringTokenizerの使い方
Javaコード
import java.util.StringTokenizer;
public class StrTokenizerDemo {
public static void main(String[] args) {
// creating string tokenizer
StringTokenizer st = new StringTokenizer(“it is a demo site will provide it skill");
// counting tokens
System.out.println(“Total tokens : " + st.countTokens());
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
}
}
実行結果
Total tokens : 9
it
is
a
demo
site
will
provide
it
skill