转载请注明作者和出处 Coder的不平凡:http://blog.csdn.net/pearyangyang/article/details/41920503 谢谢!
直接上代码:
str.replaceAll("\\s+", "")
再来看String类中replaceAll方法的详细介绍:
String str = " c s d n"; System.out.println(str.replaceAll("\\s",""));
原文地址:http://blog.csdn.net/pearyangyang/article/details/42275241