Android examples for java.util.regex:Blank Remove
remove White Spaces by regex
public class Main{ public static String removeWhiteSpaces(String str) { return str.replaceAll("\\s+", " "); }/*from w w w . j av a 2 s. c om*/ }