Java String Whitespace Delete deleteWhitespace(String str)

Here you can find the source of deleteWhitespace(String str)

Description

delete Whitespace

License

Open Source License

Declaration

public static String deleteWhitespace(String str) 

Method Source Code

//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;
    }
}

Related

  1. deleteWhitespace(CharSequence str)
  2. deleteWhitespace(final String s)
  3. deleteWhitespace(final String str)
  4. deleteWhitespace(String s)
  5. deleteWhiteSpace(String s)
  6. deleteWhitespace(String str)
  7. deleteWhitespace(String str)
  8. deleteWhitespace(String str)
  9. deleteWhitespace(String str)