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
🌐
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 - It additionally provides a few ... 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 ...
🌐
Medium
medium.com › @lp.lok.payu › isempty-vs-empty-vs-isblank-vs-isnull-12aea580fe4b
isEmpty() vs empty() vs isBlank() vs isNull() | by leela prasad | Medium
February 16, 2025 - Consider the following example. String str = " "; if (str.isBlank()) { System.out.println("String is blank"); } Checks if the value is null, empty, or contains only whitespace characters.
🌐
CodeGym
codegym.cc › java blog › strings in java › java: check if string is null, empty or blank
Java: Check if String is Null, Empty or Blank
October 11, 2023 - Both strings are null. The String = null The String = Lubaina Khan · “An empty String in Java means a String with length equal to zero.” If a String is empty that means the reference variable is referring to a memory location holding a String of length equal to zero.
🌐
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 - boolean isBlankString(String string) { return string == null || string.trim().isEmpty(); } To be precise, String#trim will remove all leading and trailing characters with a Unicode code less than or equal to U+0020.
🌐
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 - Implement similar to isEmpty() but with isBlank() for a broader check. java Copy · import org.apache.commons.lang3.StringUtils; public static boolean isNullOrEmpty(String str) { return StringUtils.isBlank(str); } Explain Code · Here, StringUtils.isBlank() checks if str is null, empty, or made solely of whitespace (spaces, tabs, new line characters).
🌐
TutorialsPoint
tutorialspoint.com › checking-for-null-or-empty-in-java
Checking for Null or Empty in Java.
The following is an example of ... method: public class CheckStringLength { public static void main(String[] args) { String input = "Ajj"; if (input.length() == 0) { System.out.println("The string is empty."); } else { System.out.println("The string is not empty."); } } } ... The string is not empty. We can check whether a particular String is empty or not, using the isBlank() method of the StringUtils class...
🌐
Educative
educative.io › answers › what-is-stringutilsisblank-in-java
What is StringUtils.isBlank in Java?
... The method returns true because the string contains only whitespace characters. ... System.out.printf("The output of StringUtils.isBlank() for the string - '%s' is %s", s, StringUtils.isBlank(s));
Find elsewhere
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-isblank-method
Java String isBlank() Method - GeeksforGeeks
July 23, 2025 - Example 2: This example demonstrates how to distinguish between an empty string ("") and a string that contains only whitespace characters. ... // Java program to distinguish between // empty and blank strings public class StringIsBlank { public static void main(String[] args) { // Array of strings String[] s = {"", " ", "Hello", " \t\n"}; // Loop through the array of strings for (int i = 0; i < s.length; i++) { // Check if the string is blank if (s[i].isBlank()) { System.out.println("String at index " + i + " is blank (contains only whitespace)."); } else { System.out.println("String at index " + i + " is not blank."); } } } }
🌐
O'Reilly
oreilly.com › library › view › jakarta-commons-cookbook › 059600706X › ch02s03.html
2.2. Checking for an Empty String - Jakarta Commons Cookbook [Book]
November 16, 2004 - Use StringUtils.isBlank() . This method will return true if it is supplied with an empty, zero length, or whitespace-only string. This method gracefully handles a null input by returning true.
Author   Timothy M. O'Brien
Published   2004
Pages   400
🌐
Reddit
reddit.com › r/askprogramming › in java, should i use (string ) isempty() or isblank() when checking an xml object for an empty value?
r/AskProgramming on Reddit: In Java, should I use (String ) isEmpty() or isBlank() when checking an XML object for an empty value?
September 26, 2022 -

I have some config file and it is deployed in many regions. Some regions have certain requirements for example lets say one region needed a username and password (basic auth). The current setup is that each deployment has it's own config file and only the instances where it is needed are these values included in the respective config.xml file.

So I have in my Java code some logic that says

'if this element is in the XML, set the corresponding variable with its value, if not do nothing'

So when I'm trying to see if that value is present or if the tag is empty/blank, which String utility should I use to check?

example code (default option left open as empty string):

if (my_config.getString(USER_ID_ELEMENT, "") != null
    & my_config.getString(PASSWORD_ELEMENT, "") != null) {
		my_userId = m_config.getString(USER_ID_ELEMENT, "");
		my_password = m_config.getString(PASSWORD_ELEMENT, "");

Here I'm checking if it is not null, but I don't think it's a very good test since I don't know if an empty XML tag is blank or is empty (i think null isn't even an option)?

🌐
BeginnersBook
beginnersbook.com › 2022 › 10 › check-if-string-is-null-empty-or-blank-in-java
Check if String is Null, Empty or Blank in Java
This method is shown in the following example. Simply compare the string with null to check for null string. Use isEmpty() method of string class to check for empty string. The isEmpty() method returns true if the string does not contain any value. Use trim() and isEmpty() method together to ...
🌐
iO Flood
ioflood.com › blog › stringutils-isempty
StringUtils.isEmpty() in Java: Your Method Guide
March 27, 2024 - StringUtils.isEmpty(str) returns false because the string is not technically ’empty’. However, StringUtils.isBlank(str) returns true, indicating that the string is either empty, null, or whitespace.
🌐
Baeldung
baeldung.com › home › java › java string › difference between string isempty() and isblank()
Difference Between String isEmpty() and isBlank() | Baeldung
December 2, 2025 - In this tutorial, we'll focus on Dapr's pub/sub API for message brokering. Using its Spring Boot integration, we'll simplify the creation of a loosely coupled, portable, and easily testable pub/sub messaging system: >> Flexible Pub/Sub Messaging With Spring Boot and Dapr · Working with Strings in Java is sometimes confusing because we have many ways to do similar things. In this article, we’ll look at how to validate blank and empty Strings using the isEmpty() and isBlank...
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string isblank method
Java String isBlank Method
September 1, 2008 - Since the string value is null, ... System.out.println("The given string is: " + str); //using isBlank() method boolean b = str.isBlank(); System.out.println("The null.isBlank() method returns: " + b); }catch(Exception e){ e.printStackTrace(); ...
🌐
Medium
medium.com › @AlexanderObregon › javas-string-isblank-method-explained-be7064a144a7
Java’s String.isBlank() Method Explained | Medium
January 10, 2025 - Example: public class ConditionalChecks ... input : inputs) { if (input == null || input.isBlank()) { System.out.println("Invalid input"); } else { System.out.println("Valid input: " + input); } } } } Output: Invalid input Invalid ...
🌐
BootcampToProd
bootcamptoprod.com › java-string-isempty-vs-isblank
Java String isEmpty vs isBlank: A Detailed Comparison - BootcampToProd
December 16, 2023 - When dealing with null strings in Java, both isEmpty() and isBlank() methods respond by throwing a NullPointerException. Remember, it’s crucial to check for null strings before using these methods to prevent unexpected errors in your code. For example, we can use the Objects class methods, such as Objects.isNull or Objects.requireNonNull, to check or enforce that a string is not null.
🌐
HowToDoInJava
howtodoinjava.com › home › java 11 › java string isblank() – check blank or empty string
Java String isBlank() - Check Blank or Empty String
December 12, 2022 - Java program to check if a given string is blank or not. "ABC".isBlank() //false " ABC ".isBlank() //false " ".isBlank() //true "".isBlank() ) //true · Both methods are used to check for blank or empty strings in java.
🌐
Codemia
codemia.io › knowledge-hub › path › checking_if_a_string_is_empty_or_null_in_java
Checking if a string is empty or null in Java
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises