I want a space -delimited string into several strings, but the number of spaces between each string is not fixed , how to split ? The call which method ?
------ Solution ---------------------------------------- ----
String str = "123 233 dfdf 8hfj";
String[] strs = str.split("\\s+");
for(String s : strs) {
System.out.println(s);
}
------ For reference only ---------------------------- -----------
split (""), then the array element trim ()
------ For reference only ------- --------------------------------
also delete the empty element
--- --- For reference only ---------------------------------------
thank three floor , the problem has been resolved , grateful
没有评论:
发表评论