Here you can find the source of deleteWhitespace(CharSequence str)
public static String deleteWhitespace(CharSequence str)
//package com.java2s; //License from project: Open Source License public class Main { public static String deleteWhitespace(CharSequence str) { StringBuilder sb = new StringBuilder(str.length()); for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (i > 0 && Character.isWhitespace(c) && Character.isWhitespace(str.charAt(i - 1))) continue; if (c == '\r' || c == '\n') { sb.append(' '); continue; }/*from ww w . j a v a2 s . c o m*/ sb.append(c); } return sb.toString(); } }