StringUtils:isNotEmpty、isNotBlank

null:
指一个字符串没有初始化,没有指向任何对象
empty:
空串 string str=“”

isNotEmpty:不为空串

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

 * <pre>
 * StringUtils.isNotEmpty(null)      = false
 * StringUtils.isNotEmpty("")        = false
 * StringUtils.isNotEmpty(" ")       = true     多个空格也不是空串
 * StringUtils.isNotEmpty("bob")     = true
 * StringUtils.isNotEmpty("  bob  ") = true
 * </pre>

isNotBlank:内容不为空,不为空白

Checks if a String is not empty (“”), not null and not whitespace only.

 * StringUtils.isNotBlank(null)      = false
 * StringUtils.isNotBlank("")        = false
 * StringUtils.isNotBlank(" ")       = false    即使有多个空格,也属于空白串
 * StringUtils.isNotBlank("bob")     = true
 * StringUtils.isNotBlank("  bob  ") = true

猜你喜欢

转载自blog.csdn.net/fle123/article/details/80596203