Here you can find the source of replaceBlank(String str)
public static String replaceBlank(String str)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static String replaceBlank(String str) { if (str != null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); str = m.replaceAll(""); }/*from w w w. j av a 2s .c om*/ return str; } public static String replaceAll(String s, String sf, String sb) { int i = 0, j = 0; int l = sf.length(); boolean b = true; boolean o = true; String str = ""; do { j = i; i = s.indexOf(sf, j); if (i > j) { str += s.substring(j, i); str += sb; i += l; o = false; } else { str += s.substring(j); b = false; } } while (b); if (o) { str = s; } return str; } }