StringUtils.isEmpty() is used to find if the String has length zero or value is null.

StringUtils.isBlank() takes it a step forward. It not only checks if the String has length zero or value is null, but also checks if it is only a whitespace string, i.e. “\s*”.


isEmpty

public static boolean isEmpty(String str)

Checks if a String is empty(“”) or null.

1
2
3
4
5
6
7
8
9
StringUtils.isEmpty(null) = true

StringUtils.isEmpty("") = true

StringUtils.isEmpty(" ") = false

StringUtils.isEmpty("bob") = false

StringUtils.isEmpty(" bob ") = false

isBlank

public static boolean isBlank(String str)

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

1
2
3
4
5
6
7
8
9
StringUtils.isBlank(null) = true

StringUtils.isBlank("") = true

StringUtils.isBlank(" ") = true

StringUtils.isBlank("bob") = false

StringUtils.isBlank(" bob ") = false