字符串分割问题
现有这样的字符串
"none 2074488 0 2074488 0%, "
需要按中间的空格分割,结果如下:
"none,2074488,0,2074488,0%, "
请问如何实现
------解决方案--------------------String str = "none 2074488 0 2074488 0%, ";
str = str.replaceAll( " + ", ", ");
System.out.println(str);
------解决方案--------------------仅供参考
String s = "none 2074488 0 2074488 0%, ";
s = s.replaceAll( "\\p{Blank} ", ", ");
------解决方案--------------------分割的话可以用StringTokenizer类。
String str = "none 2074488 0 2074488 0%, ";
StringTokenizer st=new StringTokenizer(str, " ");