Java String with not empty "" not null and not whitespace

Description

Java String with not empty "" not null and not whitespace

public class Main {
  public static void main(String[] argv) throws Exception {
    String str = "";
    System.out.println(isNotBlank(str));
  }/*from   w ww.  ja v  a 2  s  . c om*/
  public static boolean isNotBlank(String str) {
    return !isBlank(str);
  }
  public static boolean isBlank(String str) {
    int strLen;
    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;
  }

}



PreviousNext

Related