Here you can find the source of deleteWhitespace(final String str)
private static String deleteWhitespace(final String str)
//package com.java2s; //License from project: Open Source License public class Main { private static String deleteWhitespace(final String str) { if (str == null || str.isEmpty()) { return str; }/*from w ww .jav a 2 s. com*/ final int sz = str.length(); final char[] chs = new char[sz]; int count = 0; for (int i = 0; i < sz; i++) { if (!Character.isWhitespace(str.charAt(i))) { chs[count++] = str.charAt(i); } } if (count == sz) { return str; } return new String(chs, 0, count); } }