「Java8入門」split()で文字列を分割して配列にするサンプル
サンプルコード
package com.arkgame.study;
public class SplitDemo {
public static void main(String[] args) {
String strCity = "tokyo:001;oosaka:002;fukuoka:003";
String arrCity[] = strCity.split(";", 2);
for (String cft : arrCity) {
System.out.println(cft);
}
}
}
結果
tokyo:001
oosaka:002;fukuoka:003