String a = "china|hangzhou";
System.out.println(a.split("\\|")[0]);
System.out.println(a.split("\\|")[1]);
String b = "china,hangzhou";
System.out.println(b.split(",")[0]);
System.out.println(b.split(",")[1]);
split是用正则来写的,所以在分割"| ^ . *"等特殊字符时候需要进行转义!