我目前使用StringTokennizer類串轉化成不同的令牌拆分所界定的分隔符掃描器類..關於
public class App {
public static void main(String[] args) {
String str = "This is String , split by StringTokenizer, created by Neera";
StringTokenizer st = new StringTokenizer(str);
System.out.println("---- Split by comma ',' ------");
StringTokenizer st2 = new StringTokenizer(str, ",");
while (st2.hasMoreElements()) {
System.out.println(st2.nextElement());
}
}
}
我的查詢,可同樣的事情也可以通過掃描儀類也實現... !是否正確的方法來使用掃描儀類,因爲我正在閱讀掃描儀類允許標記來自循環內的數據,它允許你停下來,只要你想...我已經嘗試了以下的事情,但它doesn'工作...請告訴我.. !!!
public class App1 {
public static void main(String[] args)
{
Scanner scanner = new Scanner("This is String , split by StringTokenizer, created by Neera").useDelimiter(", ");
while (scanner.hasNextLine()) {
System.out.println(scanner.nextLine());
}
}
}
scanner.useDelimiter( 「」);問題 讀碼: http://stackoverflow.com/questions/10060843/regarding-arraylist/10060894 – Srinivas 2012-04-08 06:48:05