public static String stripWhitespace(String str) {
        char[] from = str.toCharArray();
        char[] to = new char[from.length];
        int t = 0;
        for (char c : from) {
            if (!(c == ' ' || c == '\t' || c == '\n' || c == '\r')) {
                to[t++] = c;
            }
        }
        return new String(to, 0, t);
    }