public static void main(String args[])
{
String str = "aa bb cc dd";
String test = str.replaceAll("\\s{1,}", " ");
System.out.println(test);
}
把所有多于1个的空格替换成1个空格