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
🌐
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 - ... Returns true if the string is null, empty, or only whitespace. The isNull() method is not a built-in Java method but is commonly implemented in utility classes to check for null references.
🌐
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 - If we use Maven, we need to add ... on: ... This call does the same as our own isBlankString method. It’s null-safe and also checks for whitespaces....
🌐
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)?

🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-isblank-method
Java String isBlank() Method - GeeksforGeeks
July 23, 2025 - 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 program to use isBlank() with conditional logic public class StringIsBlank { public static void main(String[] args) { // String with spaces String s = " "; // Check if the message is blank if (s.isBlank()) { System.out.println("The message is blank."); } else { System.out.println("Message: " + s); } } }
🌐
Sumo Logic
sumologic.com › log search › search query language › search operators › isnull, isempty, isblank
isNull, isEmpty, isBlank Search Operators | Sumo Logic Docs
Returns true if the string is null. Checks if the <string> value is an empty string containing no characters or whitespace.
🌐
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
Find elsewhere
🌐
Baeldung
baeldung.com › home › java › java string › difference between string isempty() and isblank()
Difference Between String isEmpty() and isBlank() | Baeldung
December 2, 2025 - 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() methods.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string isblank method
Java String isBlank Method
September 1, 2008 - The given string is: TutorialsPoint The string length is: 14 The isBlank() method returns: false The string is not a blank string. If the given string value is a null, this method throws a NullPointerException.
🌐
Medium
medium.com › @AlexanderObregon › javas-string-isblank-method-explained-be7064a144a7
Java’s String.isBlank() Method Explained | Medium
January 10, 2025 - This often resulted in repetitive code that was harder to read and maintain. With isBlank(), these checks are more direct. Consider the traditional way of validating a string for meaningful content: if (input == null || input.trim().isEmpty()) { System.out.println("Invalid input"); }
🌐
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 ...
🌐
Educative
educative.io › answers › what-is-stringutilsisblank-in-java
What is StringUtils.isBlank in Java?
The method returns true because the string points to a null reference. ... 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", ...
🌐
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 - The String = Is the String null? false Is the String empty? true The String = Lubaina Khan · “A “blank” String in Java is equal to a String with one or multiple spaces.” As mentioned before, a “blank” String is different from a scenario where a String is null or empty.
🌐
W3Schools
w3schools.com › java › ref_string_isempty.asp
Java String isEmpty() Method
This method returns true if the string is empty (length() is 0), and false if not. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com · If you want to report an ...
🌐
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.
🌐
Programiz
programiz.com › java-programming › examples › string-empty-null
Java Program to Check if a String is Empty or Null
This is because white spaces are treated as characters in Java and the string with white spaces is a regular string. Now, if we want the program to consider strings with white spaces as empty strings, we can use the trim() method. The method removes all the white spaces present in a string. ...
🌐
TutorialsPoint
tutorialspoint.com › Checking-for-Null-or-Empty-in-Java
Checking for Null or Empty in Java.
July 30, 2019 - Following is an example of checking if a string is null or empty using the isEmpty() method: public class CheckString { public static void main(String[] args) { String input = ""; if (input.isEmpty()) { System.out.println("The string is empty."); } else { System.out.println("The string is not ...
🌐
JavaTute
javatute.com › home › stringutils isempty() and isblank() example in java
StringUtils isEmpty() and IsBlank() Example in Java - JavaTute
July 18, 2020 - Syntax – public static boolean isBlank(final CharSequence cs); It returns true if any string is null or the length of the string is zero string is whitespace. Let’s see an isBlank() Example in Java.