Here you can find the source of deleteWhitespace(String str)
public static String deleteWhitespace(String str)
//package com.java2s; public class Main { public static String deleteWhitespace(String str) { if (str == null) { return null; }/* ww w . j a v a2s. co m*/ int sz = str.length(); StringBuffer buffer = new StringBuffer(sz); for (int i = 0; i < sz; i++) { if (!Character.isWhitespace(str.charAt(i))) { buffer.append(str.charAt(i)); } } return buffer.toString(); } public static boolean isWhitespace(String str) { if (str == null) { return false; } for (int i = 0, len = str.length(); i < len; i++) { if (!Character.isWhitespace(str.charAt(i))) { return false; } } return true; } }