The Apache Commons method StringUtils.isNotBlank will return false if the string is null, empty, or contains only whitespace. There will be differences in the following situations:

str1 str2 Results(1st code/2nd code)
null null false/true
"" "" false/true
" " " " false/true
Answer from k314159 on Stack Overflow
🌐
GitHub
github.com › openrewrite › rewrite-spring › issues › 475
`StringUtils#isEmpty` is not equivalent to `ObjectUtils#isEmpty` for collections · Issue #475 · openrewrite/rewrite-spring
January 12, 2024 - But the stricter check in ObjectUtils now checks if its any collection and the collection is empty or not. Its an idiosyncracy from our codebase, but the expectation from rewrite plugin was the code changes would be one-to-one, just a null check like the last impl of StringUtils would have been fine.
Author   timtebeek
🌐
Spring
docs.spring.io › spring-framework › docs › current › javadoc-api › org › springframework › util › ObjectUtils.html
ObjectUtils (Spring Framework 7.0.5 API)
public abstract class ObjectUtils extends Object · Miscellaneous object utility methods. Mainly for internal use within the framework. Thanks to Alex Ruiz for contributing several enhancements to this class! Since: 19.03.2004 · Author: Juergen Hoeller, Keith Donald, Rod Johnson, Rob Harrop, Chris Beams, Sam Brannen · See Also: ClassUtils · CollectionUtils · StringUtils ·
🌐
Apache Commons
commons.apache.org › proper › commons-lang › javadocs › api-3.9 › org › apache › commons › lang3 › ObjectUtils.html
ObjectUtils (Apache Commons Lang 3.9 API)
ObjectUtils.toString(null, null) = null ObjectUtils.toString(null, "null") = "null" ObjectUtils.toString("", "null") = "" ObjectUtils.toString("bat", "null") = "bat" ObjectUtils.toString(Boolean.TRUE, "null") = "true" Parameters: obj - the Object to toString, may be null · nullStr - the String to return if null input, may be null · Returns: the passed in Object's toString, or nullStr if null input · Since: 2.0 · See Also: StringUtils.defaultString(String,String), String.valueOf(Object) @SafeVarargs public static <T extends Comparable<? super T>> T min(T...
🌐
Spring
docs.spring.io › spring-framework › docs › current › javadoc-api › org › springframework › util › StringUtils.html
StringUtils (Spring Framework 7.0.5 API)
public StringUtils() @Deprecated(since="5.3") @Contract("null -> true") public static boolean isEmpty · (@Nullable Object str) Deprecated. in favor of hasLength(String) and hasText(String) (or ObjectUtils.isEmpty(Object)) Check whether the given object (possibly a String) is empty.
🌐
Apache Commons
commons.apache.org › proper › commons-lang › apidocs › org › apache › commons › lang3 › ObjectUtils.html
ObjectUtils (Apache Commons Lang 3.20.0 API)
ObjectUtils.toString(null, null) = null ObjectUtils.toString(null, "null") = "null" ObjectUtils.toString("", "null") = "" ObjectUtils.toString("bat", "null") = "bat" ObjectUtils.toString(Boolean.TRUE, "null") = "true" Parameters: obj - the Object to toString, may be null. nullStr - the String to return if null input, may be null. Returns: the passed in Object's toString, or nullStr if null input. Since: 2.0 · See Also: Objects.toString(Object) Objects.toString(Object, String) StringUtils.defaultString(String,String) String.valueOf(Object) public static String toString ·
🌐
GitHub
github.com › spring-projects › spring-framework › issues › 25945
Deprecate `StringUtils.isEmpty(Object)` and replace remaining usage (e.g. with `ObjectUtils.isEmpty`) · Issue #25945 · spring-projects/spring-framework
October 21, 2020 - With static imports code like this looks perfectly fine: List data = ... if (isEmpty(data)) { But if the import has StringUtils.isEmpty the condition above will not work correctly for empty List introducing a hidden, difficult to...
Author   sabi0
🌐
Medium
khmarbaise.medium.com › java-does-not-offer-stringutils-objectutils-or-collectionutils-a-supplemental-library-4f458b1be477
Java does NOT offer StringUtils, ObjectUtils or CollectionUtils (a supplemental library…
April 8, 2025 - Java does NOT offer StringUtils, ObjectUtils or CollectionUtils (a supplemental library https://commons.apache.org/proper/commons-collections/ offer that)..
Find elsewhere
🌐
GitHub
github.com › apache › commons-lang › blob › master › src › main › java › org › apache › commons › lang3 › ObjectUtils.java
commons-lang/src/main/java/org/apache/commons/lang3/ObjectUtils.java at master · apache/commons-lang
* ObjectUtils.toString(Boolean.TRUE) = "true" * </pre> * * @param obj the Object to {@code toString()}, may be {@code null}. * @return the input's {@code toString()}, or {@code ""} if the input is {@code null}. * @see Objects#toString(Object) * @see Objects#toString(Object, String) * @see StringUtils#defaultString(String) * @see String#valueOf(Object) * @since 2.0 ·
Author   apache
🌐
Medium
medium.com › @vino7tech › useful-stringutils-methods-in-java-833dc5236f0a
Useful StringUtils Methods in Java | by Vinotech | Medium
September 29, 2024 - StringUtils is a utility class commonly used in Java to perform operations on String objects. It contains a collection of static methods…
🌐
OpenRewrite
docs.openrewrite.org › recipe catalog › java › spring › spring framework › use `objectutils#isempty(object)`
Use ObjectUtils#isEmpty(Object) | OpenRewrite Docs
recipeList: - org.openrewrite.java.ChangeMethodTargetToStatic: methodPattern: org.springframework.util.StringUtils isEmpty(Object) fullyQualifiedTargetTypeName: org.springframework.util.ObjectUtils
Published   1 week ago
🌐
Educative
educative.io › answers › what-is-objectutilsisempty-in-java
What is ObjectUtils.isEmpty in Java?
Methods in Java that can be called without creating an object of the class. method of the ObjectUtils class that checks if the passed object is empty.
🌐
Medium
medium.com › javarevisited › java-the-11-utility-classes-provided-by-spring-for-writing-more-elegant-code-f9bd3c9e3b35
JAVA: The 11 Utility Classes Provided by Spring for Writing More Elegant Code | by Oliver Foster | Javarevisited | Medium
February 2, 2024 - JAVA: The 11 Utility Classes Provided by Spring for Writing More Elegant Code My article is open to everyone; non-member readers can click this link to read the full text. Today’s article is …
🌐
Eclipse Che
eclipsesource.com › blogs › 2013 › 11 › 06 › get-rid-of-your-stringutils
Get rid of your StringUtils!
June 11, 2013 - If you’re a Spring addict, the Spring framework will be part of your project anyway. Then you can as well use org.springframework.util.StringUtils which offers 40+ static methods for String parsing and manipulation.
🌐
Medium
tamerardal.medium.com › simplify-null-checks-in-java-writing-clean-code-with-apache-commons-lang-3-e7d3aea207bd
Simplify Null Checks in Java: Writing Clean Code with Apache Commons Lang 3 | by Tamer Ardal | Medium
September 18, 2024 - Integer age = ObjectUtils.defaultIfNull(inputAge, 18); Especially when working with String values, we need to do a lot of null or empty checking. In this case, we can easily do this with the StringUtils class.
🌐
GitHub
github.com › spring-cloud › spring-cloud-zookeeper › issues › 274
Replace usage of deprecated StringUtils.isEmpty with !StringUtils.hasLength · Issue #274 · spring-cloud/spring-cloud-zookeeper
January 8, 2024 - As of Spring 5.3 StringUtils.isEmpty is deprecated. The official migration hint is to either use one of the following: !StringUtils.hasLength !StringUtils.hasText To keep behaviour exactly the way it is, !StringUtils.hasLength can be use...
Author   msievers
🌐
Baeldung
baeldung.com › home › java › java string › checking for empty or blank strings in java
Checking for Empty or Blank Strings in Java | Baeldung
March 2, 2022 - Furthermore, the Spring Core library provided a class named StringUtils which has a method to check if a string is empty. However, the class was deprecated in the Spring 5.3.0 version and above. It’s replaced with the ObjectUtils class.