Tag Archives: Non null judgment

Non empty judgment method: the difference between isnotempty and isnotblank. isNullOrEmpty

In the project, we mostly use the non empty judgment method in stringutils. I believe most people have used the isnotempty or isempty method
public static Boolean isnotempty (string STR)
to judge whether a string is non empty, equal to! Isempty (string STR), where the space character cannot be excluded

Public static Boolean isnotblank (string STR)
to determine whether a string is not empty, its length is not 0, and it is not composed of whitespace! isBlank(String str)

Therefore, in many business logics, isnotblank is better than isnotempty. One is to judge whether the string is not empty and the length is not 0, and it is not composed of whitespace

isNullOrEmpty

StringUtils.IsNullOrEmpty(null) = true
StringUtils.IsNullOrEmpty("") = true
StringUtils.IsNullOrEmpty(" ") = true
StringUtils.IsNullOrEmpty("12345") = false
StringUtils.IsNullOrEmpty(" 12345 ") = false

When doing a query: List detail = systemService.findListbySql(getNewDataId);
Determine if it is emptyif (!ListUtils.isNullOrEmpty(detail)) {}