。我提议他用java.util.StringTokenization类。那个类使用起来很方便:
StringTokenizer st = new StringTokenizer("this is a test"," ");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
输出:
this
is
a
test
(构造器中第二个字符串是分隔符的集合,默认是空格)
转载于:https://my.oschina.net/abcijkxyz/blog/720511