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 › checking for empty or blank strings in java
Checking for Empty or Blank Strings in Java | Baeldung
January 8, 2024 - 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.
🌐
Baeldung
baeldung.com › home › java › java string › difference between string isempty() and isblank()
Difference Between String isEmpty() and isBlank() | Baeldung
December 2, 2025 - Notoriously, the first line tests a String that contains characters, so isEmpty() returns false. On the other hand, the second String doesn’t contain any character, and thus, isEmpty() returns true. Finally, for the String with only blank characters and the one with escape characters at lines 3 and 4, isEmpty() returns false. The isBlank() method, introduced in Java 11, is identical to isEmpty() with the nuance that it also returns true for Strings that contain only whitespace characters.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-string-isblank-method
Java String isBlank() Method - GeeksforGeeks
July 23, 2025 - 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 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); } } }
🌐
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 - Both methods are used to check for blank or empty strings in java. The difference between both methods is that: isEmpty() method returns true if, and only if, the string length is 0. isBlank() method only checks for non-whitespace characters. It does not check the string length.
🌐
Educative
educative.io › answers › what-is-stringutilsisblank-in-java
What is StringUtils.isBlank in Java?
The method returns false because the string is not null and not empty. ... The method returns true because the length of the string is zero. ... The method returns true because the string points to a null reference.
🌐
Educative
educative.io › answers › what-is-stringisblank-in-java
What is String.isBlank in Java?
public class Main { public static void main(String[] args) { String s = ""; System.out.println("\"" + s + "\" is blank - " + s.isBlank()); s = " "; System.out.println("\"" + s + "\" is blank - " + s.isBlank()); s = "h i "; System.out.println("\"" + s + "\" is blank - " + s.isBlank()); } }
Find elsewhere
🌐
Apache JIRA
issues.apache.org › jira › browse › LANG-1148
[LANG-1148] StringUtils.isBlank does not work correctly with strings containing non-breakable whitespace characters - ASF Jira
we will get 3 falses, which is not right, according to StringUtils.isBlank documentation: Checks if a String is whitespace, empty ("") or null. ... instead of looping over the string characters. I know that it is a bit less fast than it works now, but it will work much more correctly.
🌐
Tutorialspoint
tutorialspoint.com › home › java/lang › java string isblank method
Java String isBlank Method
September 1, 2008 - Following is the syntax of the Java String isBlank() method − ... It does not accept any parameter.
🌐
OpenJDK
bugs.openjdk.org › browse › JDK-8200437
[JDK-8200437] String::isBlank
In Java 8, the in place solution is awkward in its complexity. Ex. 2 // true iff is empty or only contains white space boolean blank = string.codePoints().allMatch(Character::isWhitespace); The introduction of a new method that avoids any object construction and reduces use complexity. Ex 3. // true iff is empty or only contains white space boolean blank = string.isBlank(); /** * Returns {@code true} if the string is empty or contains only * {@link Character#isWhitespace(int) white space} codepoints, * otherwise {@code false}. * * @return {@code true} if the string is empty or contains only * {@link Character#isWhitespace(int) white space} codepoints, * otherwise {@code false} * * @see Character#isWhitespace(int) * * @since 11 */ public boolean isBlank() { csr of ·
🌐
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)?

🌐
Educative
educative.io › answers › what-is-stringutilsisnotblank-in-java
What is StringUtils.isNotBlank in Java?
If a string does not satisfy any of the criteria below, then the string is considered to be not blank.
🌐
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(three)); System.out.println("Is four empty? " + StringUtils.isBlank(four)); System.out.println("Is five empty? " + 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.
🌐
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 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"); } ... In addition to these, their inverse methods also exist: StringUtils.isNotEmpty() and StringUtils.isNotBlank(), though, you can achieve the same functionality by using the NOT (!) operator:
🌐
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 - Both empty() and isEmpty() work similarly but have some differences in their synchronization behavior. The empty() method is synchronized, while isEmpty() is not. This can lead to different performance characteristics in multi-threaded environments. Blank strings are those strings that contain only white spaces. The isEmpty() method comes in very handy to check for the blank strings. In Java version 11, the isBlank() method was introduced for String objects.
🌐
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 - 2.2. Checking for an Empty StringProblemYou need to test for an empty or null string.SolutionUse StringUtils.isBlank() . This method will return true if it is supplied with an... - Selection from Jakarta Commons Cookbook [Book]
Author   Timothy M. O'Brien
Published   2004
Pages   400
🌐
Medium
medium.com › @AlexanderObregon › javas-string-isblank-method-explained-be7064a144a7
Java’s String.isBlank() Method Explained | Medium
January 10, 2025 - While isBlank() is efficient for most cases, it may introduce noticeable delays when processing very large strings repeatedly in performance-critical applications.