Example usage for java.lang Character isWhitespace

List of usage examples for java.lang Character isWhitespace

Introduction

In this page you can find the example usage for java.lang Character isWhitespace.

Prototype

public static boolean isWhitespace(int codePoint) 

Source Link

Document

Determines if the specified character (Unicode code point) is white space according to Java.

Usage

From source file:Main.java

private static int getEndIndex(CharSequence input) {
    int index = input.length() - 1;
    while (Character.isWhitespace(input.charAt(index))) {
        --index;//from www .  j a  v a 2 s  .co  m
        if (index < 0) {
            break;
        }
    }
    return index;
}

From source file:Main.java

private static int getStartIndex(CharSequence input) {
    int length = input.length();
    int index = 0;
    while (Character.isWhitespace(input.charAt(index))) {
        ++index;// w  w w. j a  va  2  s .  c o  m
        if (index >= length) {
            break;
        }
    }
    return index;
}

From source file:Main.java

public static boolean isWhitespace(String s) {
    boolean ok = true;
    for (int i = 0; i < s.length(); i++)
        ok = ok && Character.isWhitespace(s.charAt(i));
    return ok;// ww w  .  j  ava 2s .c om

}

From source file:Main.java

private static boolean isSpace(String s) {
    if (s == null)
        return true;
    for (int i = 0, len = s.length(); i < len; ++i) {
        if (!Character.isWhitespace(s.charAt(i))) {
            return false;
        }//from   w  ww.ja va2s  . co  m
    }
    return true;
}

From source file:Main.java

public static boolean isEmptyText(Text txt) {
    String s = txt.getData();/*from   w ww . j a v a  2 s  .  c o m*/
    for (int i = 0; i < s.length(); ++i) {
        if (!Character.isWhitespace(s.charAt(i)))
            return false;
    }
    return true;
}

From source file:Main.java

public static boolean isAlpha(String name) {
    char[] chars = name.toCharArray();

    for (char c : chars) {
        if (!Character.isLetter(c)) {
            if (!Character.isWhitespace(c)) {
                return false;
            }/*w  w w . j  a  va  2 s  .  com*/
        }
    }
    return true;
}

From source file:Main.java

public static boolean isNullOrWhiteSpace(String str) {
    if (str == null || str.isEmpty()) {
        return true;
    }//from   ww w.  j  a  v  a 2  s .c  om
    for (char c : str.toCharArray()) {
        if (!Character.isWhitespace(c)) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

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

From source file:Main.java

public static boolean isEmptyOrWhitespace(String str) {
    if (TextUtils.isEmpty(str)) {
        return true;
    }/*  www.  java 2s. co  m*/
    for (int i = 0; i < str.length(); i++) {
        if (!Character.isWhitespace(str.charAt(i))) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

public static boolean is_str_blank(String str) {
    int length;/*from w ww . j a va2 s .  c  om*/

    if ((str == null) || ((length = str.length()) == 0)) {
        return true;
    }

    for (int i = 0; i < length; i++) {
        if (!Character.isWhitespace(str.charAt(i))) {
            return false;
        }
    }
    return true;
}