The difference between IsEmpty and Isblank in StringUtils

Source: Internet
Author: User
StringUtils in Commons-lang-2.2.jar bag: org.apache.commons.lang.StringUtils;

The action object of the StringUtils method is an object of type java.lang.String, a supplement to the string manipulation method provided by the JDK, and Null is safe ( That is, if the input parameter string is NULL, the NullPointerException is not thrown, but the corresponding processing is done, for example, if the input is null, the return is NULL, etc., you can view the source code.

In addition to the constructor, there are more than 130 methods in StringUtils, and all are static, so we can call Stringutils.xxx ()

1. public static Boolean IsEmpty (String str)
The criterion for determining whether a string is empty is Str==null or str.length () ==0

The following is an example of whether StringUtils is empty:
Stringutils.isempty (NULL) = True
Stringutils.isempty ("") = True
Stringutils.isempty ("") = false//note in StringUtils Hollow space for non-null processing

Stringutils.isempty ("Bob") = False
Stringutils.isempty ("Bob") = False

2. public static Boolean isnotempty (String str)
Determines whether a string is non-null, equal to!isempty (string str)

Here is an example:
Stringutils.isnotempty (NULL) = False
Stringutils.isnotempty ("") = False
Stringutils.isnotempty ("") = True

Stringutils.isnotempty ("Bob") = True
Stringutils.isnotempty ("Bob") = True

3. public static Boolean IsBlank (String str)
Determines whether a string is empty or length 0 or is composed of a blank character (whitespace)

Here is an example:
Stringutils.isblank (NULL) = True
Stringutils.isblank ("") = True
Stringutils.isblank ("") = True

Stringutils.isblank ("\ \ \ n \f \ r") = TRUE//is known as a blank character for tabs, line breaks, feed and return Stringutils.isblank ()
Stringutils.isblank ("\b") = false//"\b" for word boundary character
Stringutils.isblank ("Bob") = False
Stringutils.isblank ("Bob") = False

4. public static Boolean Isnotblank (String str)
Determines whether a string is not empty and has a length of 0 and is not composed of whitespace characters (whitespace) equal to!isblank (string str)

Here is an example:
Stringutils.isnotblank (NULL) = False
Stringutils.isnotblank ("") = False
Stringutils.isnotblank ("") = False

Stringutils.isnotblank ("\ \ n \f \ r") = False
Stringutils.isnotblank ("\b") = true
Stringutils.isnotblank ("Bob") = True
Stringutils.isnotblank ("Bob") = True

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.