All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.groupbyinc.util.StringUtils Maven / Gradle / Ivy

There is a newer version: 198
Show newest version
package com.groupbyinc.util;

public class StringUtils {

  /**
   * 

Checks if a CharSequence is empty (""), null or whitespace only.

* *

Whitespace is defined by {@link Character#isWhitespace(char)}.

* *
   * StringUtils.isBlank(null)      = true
   * StringUtils.isBlank("")        = true
   * StringUtils.isBlank(" ")       = true
   * StringUtils.isBlank("bob")     = false
   * StringUtils.isBlank("  bob  ") = false
   * 
* * @param cs the CharSequence to check, may be null * @return {@code true} if the CharSequence is null, empty or whitespace only */ public static boolean isBlank(final CharSequence cs) { int strLen; if (cs == null || (strLen = cs.length()) == 0) { return true; } for (int i = 0; i < strLen; i++) { if (!Character.isWhitespace(cs.charAt(i))) { return false; } } return true; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy