Updated answer of Bojo and Jan-59 for reference:
ObjectUtils.toString(object) from commons-lang. There is actually one line in the code:
return obj == null ? "" : obj.toString();
However, this method in Apache Commons is now deprecated after release 3.2 (commons / lang3). Their goal was to remove all methods available in Jdk7. This method has been replaced by java.util.Objects.toString(Object) in Java 7 and is likely to be removed in future versions. After some discussion, they have not deleted it yet (currently in 3.4), and it is still available as an obsolete method.
Note that the specified java 7+ method returns "null" for null references, while this method also returns an empty string. To keep using behavior
java.util.Objects.toString(myObject, "")
Nick Vanderhoven Jun 23 '15 at 8:06 2015-06-23 08:06
source share