Here you can find the source of removeSpace(String str)
public static String removeSpace(String str)
//package com.java2s; import android.text.TextUtils; public class Main { public static String removeSpace(String str) { if (!TextUtils.isEmpty(str)) { return str.trim().replaceAll(" ", ""); } else {//from ww w. jav a 2s. c om return str; } } public static boolean isEmpty(String str) { if (str == null || "".equals(str)) return true; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c != ' ' && c != '\t' && c != '\r' && c != '\n') { return false; } } return true; } }