StringUtils.isBlank() vs String.isEmpty()

StringUtils.isBlank() vs String.isEmpty() :

StringUtils.isBlank() will also check for null, whereas this:

String foo = getvalue("foo");
if (foo.isEmpty())

will throw a NullPointerException if foo is null.

Second Solv –

StringUtils.isBlank also returns true for just whitespace:

isBlank(String str)

Checks if a String is whitespace, empty ("") or null.

Leave a Comment