java learnging

一块探讨JAVA的奥妙吧
posts - 34, comments - 27, trackbacks - 0, articles - 22

导航

公告

big_seal@msn.com
<2005年7月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿(3)

随笔档案

文章档案

相册

收藏夹

Blog站点

favorite blog

java website

java基础

my blog

other blog

temp link

个人Blog

搜索

  •  

最新评论

阅读排行榜

评论排行榜

java API

Posted on 2005-07-22 18:00 bigseal 阅读(1293) 评论(0)  编辑  收藏

java.util.*

java.util.StringTokenizer
作用: 根据标记分割字符串
例子:

StringTokenizer st = new StringTokenizer("this is a test");
     
while (st.hasMoreTokens()) {
         System.
out.println(st.nextToken());
     }
结果为:
     this
     is
     a
     test

但是该类已经不推荐使用了,如果要实现该功能可以通过String类的split方法或 java.util.regex package来代替。
     String[] result = "this is a test".split("\\s");
     
for (int x=0; x<result.length; x++)
         System.
out.println(result[x]);
结果为:
     this
     is
     a
     test

只有注册用户登录后才能发表评论。


网站导航: