「Java入門」java.util.StringTokenizerの使い方
Javaコード
import java.util.StringTokenizer;
public class TokenizerDemo {
public static void main(String[] args) {
String dig = “Tokyo/Fukuoka/Oosaka/Okinawa";
String delim = “/";
StringTokenizer st = new StringTokenizer(dig, delim);
int count = st.countTokens();
String[] cft = new String[count];
for (int i = 0; i < count; i++) {
cft[i] = st.nextToken();
System.out.println(cft[i]);
}
}
}
結果
Tokyo
Fukuoka
Oosaka
Okinawa