is Blank string check by Character.isWhitespace - Android java.lang

Android examples for java.lang:Character

Description

is Blank string check by Character.isWhitespace

Demo Code


public class Main{

    public static boolean isBlank(String str) {
        int len;//from w w  w.j a v  a  2  s . com
        if ((str == null) || ((len = str.length()) == 0))
            return true;
        for (int i = 0; i < len; i++) {
            if (!Character.isWhitespace(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }

}

Related Tutorials