public static String removeExtraSpaces(String text){
  text=text.replace(ChineseLanguageConstants.SPACE[0],ChineseLanguageConstants.SPACE[1]);
  text=text.replaceAll("[ \t\u000B\u000C\u00A0\uE5F1]+"," ");
  text=text.replaceAll("(^ +)|( +$)","");
  return text;
}

public static String removeExtraSpaces ( String text ) { text = text . replace ( ChineseLanguageConstants . SPACE [ 0 ] , ChineseLanguageConstants . SPACE [ 1 ] ) ; text = text . replaceAll ( "[ \t ]+" , " " ) ; text = text . replaceAll ( "(^ +)|( +$)" , "" ) ; return text ; }
remove extra spaces , which means more than one continuous spaces will be reduced to one space . space here is not limited to the % 32 white space character , it also includes tab , space in chinese full width letter and other special characters which appear as a white space . spaces in the begin or end of a line are all removed .
