The criterion for determining whether a string is empty is str==null or str.length()==0
1. The following is an example of whether StringUtils is empty:
StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false //Note that the spaces are non-empty in StringUtils StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty("bob ") = false2. public static boolean isNotEmpty(String str)
Determine whether a string is not empty, equal to !isEmpty(String str)
Here is an example:
StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty(" bob ") = true StringUtils.isNotEmpty(" bob ") = true3. public static boolean isBlank(String str)
Determine whether a string is empty or has a length of 0 or is composed of a whitespace character (whitespace)
Here is an example:
StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("/t /n /f /r") = true //For tabs, line breaks, page breaks and carriage return StringUtils.isBlank() //All are recognized as blanks StringUtils.isBlank("/b") = false //"/b" is the word boundary character StringUtils.isBlank("bob") = false StringUtils.isBlank("bob") = false StringUtils.isBlank("bob ") = false4. public static boolean isNotBlank(String str)
Determine whether a string is not empty, its length is not 0, and it is not composed of whitespace, which is equal to !isBlank(String str)
Here is an example:
StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("/t /n /f /r") = false StringUtils.isNotBlank("/b") = true StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank("bob") = trueSummarize
The above is all the content of this article about the analysis of the StringUtils tool class in Java that the String is empty. I hope it will be helpful to everyone. Interested friends can continue to refer to other related topics on this site. If there are any shortcomings, please leave a message to point it out. Thank you friends for your support for this site!