我目前正在使用StringTokennizer
类通过定义的分隔符将字符串拆分为不同的标记
public class App {
public static void main(String[] args) {
String str = "This is String , split by StringTokenizer, created by saral";
StringTokenizer st = new StringTokenizer(str);
System.out.println("---- Split by comma ',' ------");
StringTokenizer st2 = new StringTokenizer(str, ",");
while (st2.hasMoreElements()) {
System.out.println(st2.nextElement());
}
}
}
请告诉我更多替代方法来实现这一点,如 jdk 5 支持扫描仪和 java .util,正则表达式......!请指教..!!