StringUtils.isBlank() checks that each character of the string is a whitespace character (or that the string is empty or that it's null). This is totally different than just checking if the string is empty.

From the linked documentation:

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

 StringUtils.isBlank(null)      = true
 StringUtils.isBlank("")        = true  
 StringUtils.isBlank(" ")       = true  
 StringUtils.isBlank("bob")     = false  
 StringUtils.isBlank("  bob  ") = false

For comparison StringUtils.isEmpty:

 StringUtils.isEmpty(null)      = true
 StringUtils.isEmpty("")        = true  
 StringUtils.isEmpty(" ")       = false  
 StringUtils.isEmpty("bob")     = false  
 StringUtils.isEmpty("  bob  ") = false

Warning: In java.lang.String.isBlank() and java.lang.String.isEmpty() work the same except they don't return true for null.

java.lang.String.isBlank() (since Java 11)

java.lang.String.isEmpty()

Answer from arshajii on Stack Overflow
🌐
Educative
educative.io › answers › what-is-stringutilsisempty-in-java
What is StringUtils.isEmpty in Java?
isEmpty() is a static method of ... the string is considered to be empty. The length of the string is zero. The string points to a null reference....
🌐
DEV Community
dev.to › niharmore33 › comment › 8hk
You should leverage StringUtils.isEmpty(str), which checks for empty strings ... - DEV Community
You should leverage StringUtils.isEmpty(str), which checks for empty strings and handles null gracefully.
🌐
AWS
sdk.amazonaws.com › java › api › latest › software › amazon › awssdk › utils › StringUtils.html
StringUtils (AWS SDK for Java - 2.42.1)
Checks if a CharSequence is empty ("") or null. StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
🌐
iO Flood
ioflood.com › blog › stringutils-isempty
StringUtils.isEmpty() in Java: Your Method Guide
March 27, 2024 - StringUtils.isEmpty is a method in the Apache Commons Lang library that checks if a given string is empty or null.
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.9 › org › apache › commons › lang3 › StringUtils.html
StringUtils (Apache Commons Lang 3.9 API)
Checks if a CharSequence is empty ("") or null. StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
🌐
Kodejava
kodejava.org › how-do-i-check-for-an-empty-string
How do I check for an empty string? - Learn Java by Examples
" + StringUtils.isBlank(five)); // On the other side, the StringUtils.isNotBlank() methods complement // the previous method. It will check if a tested string is not empty. System.out.println("Is one not empty? " + StringUtils.isNotBlank(one)); System.out.println("Is two not empty?
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java string › checking for empty or blank strings in java
Checking for Empty or Blank Strings in Java | Baeldung
January 8, 2024 - The ObjectUtils class provides the isEmpty() method to check if a string is empty: ... Like Guava, it won’t check if a string only contains whitespace but checks whether a given string is null or empty.
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-2.6 › org › apache › commons › lang › StringUtils.html
StringUtils (Commons Lang 2.6 API)
public class StringUtils · extends Object · Operations on String that are null safe. IsEmpty/IsBlank - checks if a String contains text · Trim/Strip - removes leading and trailing whitespace · Equals - compares two strings null-safe · startsWith - check if a String starts with a prefix ...
🌐
Vultr Docs
docs.vultr.com › java › examples › check-if-a-string-is-empty-or-null
Java Program to Check if a String is Empty or Null | Vultr Docs
December 17, 2024 - Use StringUtils.isEmpty() to check ... StringUtils.isEmpty(str); } Explain Code · StringUtils.isEmpty() internally checks for null and empty strings, making your code cleaner and more expressive....
🌐
AWS
sdk.amazonaws.com › java › api › 2.1.3 › software › amazon › awssdk › utils › StringUtils.html
StringUtils (AWS SDK for Java - 2.1.3)
Checks if a CharSequence is empty ("") or null. StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false
🌐
Stack Abuse
stackabuse.com › java-check-if-string-is-null-empty-or-blank
Java: Check if String is Null, Empty or Blank
February 28, 2023 - One of the key differences between StingUtils and String methods is that all methods from the StringUtils class are null-safe. It additionally provides a few methods that we can leverage for this, including StringUtils.isEmpty() and StringUtils.isBlank(): String nullString = null; if (nullString == null) { System.out.println("String is null"); } else if (StringUtils.isEmpty(nullString)) { System.out.println("String is empty"); } else if (StringUtils.isBlank(nullString)) { System.out.println("String is blank"); } The output will be: String is null ·
🌐
Spring
docs.spring.io › spring-framework › docs › current › javadoc-api › org › springframework › util › StringUtils.html
StringUtils (Spring Framework 7.0.5 API)
public StringUtils() @Deprecated(since="5.3") @Contract("null -> true") public static boolean isEmpty · (@Nullable Object str) Deprecated. in favor of hasLength(String) and hasText(String) (or ObjectUtils.isEmpty(Object)) Check whether the given object (possibly a String) is empty.
🌐
Reddit
reddit.com › r/learnjava › best way to check for null on strings?
Best way to check for null on Strings? : r/learnjava
May 8, 2024 - Plus "someString == null" will always be false since the result of String.valueOf will never be null. edit after reading josephblade's answer : +1 on the "optional is probably not what you want". [deleted] • 2y ago • Edited 2y ago · I think StringUtil.isEmpty will check if it's "" or null.
🌐
DEV Community
dev.to › monknomo › finding-null-or-empty-string-checks-in-java › comments
[Discussion] Finding Null or Empty String Checks in Java — DEV Community
System.out.println(StringUtils.isEmpty("")); // true System.out.println(StringUtils.isEmpty(null)); // true Google Guava also provides a similar, probably easier-to-read method: Strings.isNullOrEmpty(str).