StringUtils.isNotEmpty() is used to find if the String is not empty and not null.

StringUtils.isNotBlank() takes it a step forward. It not only checks if the String is not empty and not null, but also checks if it is not only a whitespace string.


isNotEmpty

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

1
2
3
4
5
6
7
8
9
StringUtils.isNotEmpty(null)      = false

StringUtils.isNotEmpty("") = false

StringUtils.isNotEmpty(" ") = true

StringUtils.isNotEmpty(" lol ") = true

StringUtils.isNotEmpty("lol") = true

isNotBlank

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

1
2
3
4
5
6
7
8
9
StringUtils.isNotBlank(null)      = false

StringUtils.isNotBlank("") = false

StringUtils.isNotBlank(" ") = false

StringUtils.isNotBlank("lol") = true

StringUtils.isNotBlank(" lol ") = true