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
🌐
Baeldung
baeldung.com › home › java › java string › difference between string isempty() and isblank()
Difference Between String isEmpty() and isBlank() | Baeldung
December 2, 2025 - The above table summarizes that if the String doesn’t contain any character, both methods return true. Additionally, the escape sequences \t, \n, \r, \f, and \s are considered whitespace characters, so only isBlank() returns true. In contrast, isEmpty() returns false for all of them. Finally, for any other character different from the ones shown in the table, both methods return false. Before Java 11, developers typically used the combination of String.trim() and String.isEmpty() to validate that a text contains only whitespace characters.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string isblank method
Java String isBlank Method
September 1, 2008 - IIn the below example, we are creating a string literal with the null value. Using the isBlank() method, we are trying to check whether the string is blank or not. Since the string value is null, the method throws an exception. import java.lang.*; ...
🌐
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 - Like Guava, it won’t check if a string only contains whitespace but checks whether a given string is null or empty. There are several ways to check whether a string is empty or not. Often, we also want to check if a string is blank, meaning that it consists of only whitespace characters. The most convenient way is to use Apache Commons Lang, which provides helpers such as StringUtils.isBlank. If we want to stick to plain Java, we can use a combination of String#trim with either String#isEmpty or String#length.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-isblank-method
Java String isBlank() Method - GeeksforGeeks
July 23, 2025 - String at index 1 is blank (contains only whitespace). String at index 2 is not blank. String at index 3 is blank (contains only whitespace). Example 3: This example shows how to use isBlank() with conditional logic to handle blank inputs in an application. Java ·
🌐
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 - String string = "Hello there"; if (string == null || string.equals("") || string.trim().equals("")) System.out.println("String is null, empty or blank"); else System.out.println("String is neither null, empty nor blank"); In much the same fashion as the before, if the trimmed string is "", ...
🌐
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.
🌐
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
🌐
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 - Here, StringUtils.isBlank() checks if str is null, empty, or made solely of whitespace (spaces, tabs, new line characters). Very useful when the mere presence of whitespace should also classify the string as "empty". Recognize the enhancements in Java 11 including new String methods.
🌐
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
String myString = ""; //empty string if(myString!=null && myString.isEmpty()){ System.out.println("This is an empty string"); } A blank string contains only whitespaces. String str = " "; //there is a whitespace between quotes · The length of a blank string is not zero, the isEmpty() method ...
🌐
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 - In other words, a String with only white space characters is blank but not empty. "ABC".isBlank() //false " ".isBlank() //true "ABC".isEmpty() //false " ".isEmpty() //false · Happy Learning !! ... A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies.
🌐
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)?

🌐
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 - The following example demonstrates isBlank( ) with four strings: String test = ""; String test2 = "\n\n\t"; String test3 = null; String test4 = "Test"; System.out.println( "test blank?
Author   Timothy M. O'Brien
Published   2004
Pages   400
🌐
TutorialsPoint
tutorialspoint.com › Checking-for-Null-or-Empty-in-Java
Checking for Null or Empty in Java.
The following is an example of checking if a string is null or empty using the length() 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.
🌐
BootcampToProd
bootcamptoprod.com › java-string-isempty-vs-isblank
Java String isEmpty vs isBlank: A Detailed Comparison - BootcampToProd
December 16, 2023 - Alternatively, we can use the StringUtils class methods from Apache Commons Lang, such as StringUtils.isEmpty or StringUtils.isBlank, which return true for null values, as well as empty or blank values. The main difference between the isEmpty and isBlank methods is that the isEmpty method only checks the length of the string, while the isBlank method also checks the characters of the string.
🌐
iO Flood
ioflood.com › blog › stringutils-isempty
StringUtils.isEmpty() in Java: Your Method Guide
March 27, 2024 - Here’s an example of importing the StringUtils class in your Java code: ... With this import statement, you can now use any of the methods provided by StringUtils, including isEmpty, isBlank, and many others. In Java, a string is considered empty if it is not null and its length is zero.