/将str中的空字符替换为replaceStr,替换后的字符串为strAfter
String arr="aaa bbb   ccc";
String replaceStr="";
Pattern p = Pattern.compile("\\s*|\t|\r|\n");      
Matcher m = p.matcher(str);      
String strAfter = m.replaceAll(replaceStr);   
System.out.println(strAfter);