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
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-isblank-method
Java String isBlank() Method - GeeksforGeeks
July 23, 2025 - Example 1: In this example, we will use the basic approach to check if a given string is blank (empty or contains only whitespace) using isBlank() method. ... // Java program to demonstrate isBlank() method public class StringIsBlank { public static void main(String[] args) { // Declare and initialize strings String s1 = " "; // String with only spaces String s2 = "Hello, World!"; // Non-empty string // Check if the strings are blank System.out.println(s1.isBlank()); System.out.println(s2.isBlank()); } }
🌐
Medium
medium.com › @AlexanderObregon › javas-string-isblank-method-explained-be7064a144a7
Java’s String.isBlank() Method Explained | Medium
January 10, 2025 - The introduction of isBlank() eliminates the need for repetitive code patterns that involve trimming strings or writing custom checks to handle whitespace scenarios.
🌐
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 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.
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › docs › api › java.base › java › lang › String.html
String (Java SE 17 & JDK 17)
January 20, 2026 - Otherwise, if the string has no terminators, the last line is the start of the string to the end of the string, in other words, the entire string. A line does not include the line terminator. Then, the minimum indentation (min) is determined as follows: For each non-blank line (as defined by isBlank()), the leading white space characters are counted.
🌐
KooR
koor.fr › Java › API › java › lang › String › isBlank.wp
KooR.fr - Méthode java.lang.String.isBlank
Gérer la persistance des données ... · public boolean isBlank(); Cette méthode permet de vérifier si la chaîne est vide ou si elle ne contient que des caractères d'espacements (white spaces)....
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string isblank method
Java String isBlank Method
September 1, 2008 - Discover how to use the Java String isBlank method to determine if a string is empty or only contains whitespace characters.
🌐
Educative
educative.io › answers › what-is-stringisblank-in-java
What is String.isBlank in Java?
isBlank() is an instance method that returns true if the string is empty or contains only white space codepoints. This method was introduced in Java 11.
Find elsewhere
🌐
Tabnine
tabnine.com › home page › code › java › java.lang.string
java.lang.String.isBlank java code examples | Tabnine
public MetadataItem(Class<?> serviceProvider, Metadata holder) { providerName = serviceProvider.getName(); activateMethodName = holder.properties().getProperty(providerName + ACTIVATE_SUFFIX); var refs = holder.properties().getProperty(providerName + REFS_SUFFIX); if (refs != null && !refs.isBlank()) { var tokens = refs.split(COMMA); references = new ArrayList<>(tokens.length); for (String t : tokens) { references.add(new Reference(t, holder.module().getLayer())); } } else { references = List.of(); } }
🌐
Educative
educative.io › answers › what-is-stringutilsisblank-in-java
What is StringUtils.isBlank in Java?
isBlank() is a · static · the methods in Java that can be called without creating an object of the class. method of the StringUtils which is used to check if the given string is blank.
🌐
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.
🌐
Java Guides
javaguides.net › 2024 › 01 › string-isempty-vs-isblank-in-java.html
String isEmpty() vs String isBlank() in Java
June 15, 2024 - ▶️ Subscribe to My YouTube Channel (178K+ subscribers): Java Guides on YouTube · ▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube · In Java, the String class provides multiple methods to check if a string is empty or consists only of whitespace. Two commonly used methods for this purpose are isEmpty() and isBlank...
🌐
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.
🌐
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)?

🌐
BootcampToProd
bootcamptoprod.com › java-string-isempty-vs-isblank
Java String isEmpty vs isBlank: A Detailed Comparison - BootcampToProd
December 16, 2023 - String str1 = ""; // an empty string String str2 = " "; // a string with a space String str3 = "Hello"; // a string with characters String str4 = "\n\t\r\f"; // a string with escape sequences System.out.println(str1.isEmpty()); // true, because str1 has no characters System.out.println(str2.isEmpty()); // false, because str2 has 1 character (a space) System.out.println(str3.isEmpty()); // false, because str3 has 5 characters System.out.println(str4.isEmpty()); // false, because str4 has 4 characters (escape sequences) System.out.println(str1.isBlank()); // true, because str1 has no characters
🌐
OneCompiler
onecompiler.com › java › 3x46egx3m
String isBlank - Java - OneCompiler
In Java 11 a new method called isBlank() is added in the String class. The isBlank method will return true If the string is empty If the string only contains whitespace.
🌐
Microsoft Learn
learn.microsoft.com › en-us › dotnet › api › java.lang.string.isblank
String.IsBlank Property (Java.Lang) | Microsoft Learn
Returns true if the string is empty or contains only Character#isWhitespace(int) white space codepoints, otherwise false. public bool IsBlank { [Android.Runtime.Register("isBlank", "()Z", "", ApiSince=33)] get; } [<get: Android.Runtime.Regi...