The difference between Isnotempty and Isnotblank in StringUtils "Java string null"

Source: Internet
Author: User
Tags control characters



1 isnotempty (str) equivalent to str! = NULL && str.length > Isnotblank (str) equivalent to str! = NULL && str.length > 0 && Str.trim (). length > 03 similarly 4 isEmpty equivalent to str = = NULL | | Str.length = = IsBlank  equivalent to str = = NULL | | str.length = = 0 | | Str.trim (). length = 7 str.length > 0 && Str.trim (). length > 0  --->   str.length > 0

  The operand of the 1 StringUtils method is an object of type java.lang.String, complements the string type operation method provided by the JDK, and is null-safe (  That is, if the input parameter, string null, does not throw a nullpointerexception, but does the corresponding processing, for example, if the input is null, the return is also NULL, etc., you can view the source code). 2 3 4 In addition to the constructor, there are more than 130 methods in StringUtils, and all are static, so we can call Stringutils.xxx () 5 6 7 1. public static Boolean IsEmpty (String str) 8 determines whether a string is empty, the standard for null is Str==null or str.length () ==0 9 The following is an example of whether the stringutils is empty: Ten str Ingutils.isempty (NULL) = True One Stringutils.isempty ("") = True Stringutils.isempty ("") = false//Note in the StringUtils Hollow lattice made non-empty Processing Stringutils.isempty ("") = False Stringutils.isempty ("Bob") = False Stringutils.isempty ("Bob") = False 16 1 7 18 2. public static Boolean Isnotempty (String str) 19 determines whether a string is non-null, equal to!isempty (string str) 20 Below is an example: Stringutils.isnotempty (nul L) = False Stringutils.isnotempty ("") = False Stringutils.isnotempty ("") = True Stringutils.isnotempty ("") = TR UE Stringutils.isnotempty ("Bob") = True Stringutils.isnotempty ("Bob") = True 27 28 29 3. public static BooleanIsBlank (String str) 30 determines whether a string is empty or has a length of 0 or is composed of a white space character (whitespace) 31 Here is an example: Stringutils.isblank (NULL) = True stringutils.is Blank ("") = True Stringutils.isblank ("") = True Stringutils.isblank ("") = True Stringutils.isblank ("\ t \ n \f \ r ") = TRUE//For tab characters, newline characters, page breaks, and carriage return Stringutils.isblank () are known as whitespace characters stringutils.isblank (" \b ") = false//" \b "for word boundary character 38 Stringutils.isblank ("Bob") = False Stringutils.isblank ("Bob") = False 40 41 42 4. public static Boolean Isnotblank (String str) 43 Determines whether a string is not empty and is not 0 in length and is not composed of a white space character (whitespace), which is equal to!isblank (string str) 44 Below is an example: Stringutils.isnotblank (NULL) = False Stringutils.isnotblank ("") = False Stringutils.isnotblank ("") = False Ringutils.isnotblank ("") = False Stringutils.isnotblank ("\ t \ n \ \f \ r") = False Stringutils.isnotblank ("\b") = true Wuyi Stringutils.isnotblank ("Bob") = True Stringutils.isnotblank ("Bob") = True 53 54 55 Other methods introduced: 56 5. public static string trim (String str) 57 removes the control characters, Char <= 32, from both ends of the string.Returns NULL if the input is null 58 The following is an example: Stringutils.trim (NULL) = null Stringutils.trim ("") = "" Stringutils.trim ("") = "" "62 Stringutils.trim ("\b \ n \ \f \ r") = "" "Stringutils.trim (" \n\tss \b ") =" ss "+ Stringutils.trim (" D d dd ") =" D D DD "Stringutils.trim (" dd ") =" dd "Stringutils.trim (" dd ") =" DD "67 68 69 6. public static string Trimtonull (String str) 70 removes the control character at both ends of the string (control characters, Char <= 32), or null 71 if it becomes null or "", the following is an example : Stringutils.trimtonull (NULL) = null stringutils.trimtonull ("") = null Stringutils.trimtonull ("") = null for the STR Ingutils.trimtonull ("\b \ n \ \f \ r") = null stringutils.trimtonull ("\n\tss \b") = "ss" Stringutils.trimtonull (" D d dd ") =" D d dd "Stringutils.trimtonull (" dd ") =" dd "stringutils.trimtonull (" dd ") =" dd "80 81 82 7.  public static string Trimtoempty (String str) 83 removes the control character at both ends of the string (control characters, Char <= 32), and returns "" 84 if it becomes null or "", the following is an example: Stringutils.trimtoempty (NULL) = "" Stringutils.trimtoempty("") = "" Stringutils.trimtoempty ("") = "" Stringutils.trimtoempty ("\b \ n \ \f \ r") = "" "Stringutils.trimtoem Pty ("\n\tss \b") = "ss" Stringutils.trimtoempty ("D d dd") = "D d dd" Stringutils.trimtoempty ("dd") = "dd" for the Str Ingutils.trimtoempty ("dd") = "DD" 93 94 95 8. public static string strip (String str) 96 removes whitespace characters (whitespace) at both ends of the string, or null if input is NULL 97 below is an example (note and trim () difference): 98 Stringutils.strip (NULL) = null Stringutils.strip ("") = "" "Stringutils.strip (" ") =" "101 stringutils.strip (" \b \ t \ n \f \ r ") =" \b "102 stringutils.strip (" \n\tss \b ") =" ss \b "103 stringutils.strip (" D-d dd ") =" D d DD "104 stringutils. Strip ("dd") = "dd" Stringutils.strip ("dd") = "DD" 106 107 108 9. public static string Striptonull (String str) 109 takes away the white space character (whitespace) at both ends of the string and, if it becomes null or "", returns null110 below is an example (note and Trimtonull () Difference): 111 stringutils.striptonull (NULL) = null112 Stringutils.striptonull ("") = null113 Stringutils.striptonull ("") = null114 stringutils.striptonull ("\b \ n \ \f \ r ") =" \b "stringutils.striptonull (" \n\tss \b ") =" ss \b "for the stringutils.striptonull (" D d dd ") =" D d DD "117 Stringu Tils.striptonull ("dd") = "DD" 118 stringutils.striptonull ("dd") = "DD" 119 120 121 10. public static string Striptoempty (String str) 122 takes away whitespace characters (whitespace) at both ends of the string, and returns "" 123 if it becomes null or "", the following is an example (note and Trimtoempty () Difference): 124 stringutils.striptonull (NULL) = "" "Stringutils.striptonull (" ") =" "126 Stringutils.striptonull (" ") =" "127 S Tringutils.striptonull ("\b \ \ \ \f \ r") = "\b" stringutils.striptonull ("\n\tss \b") = "ss \b" 129 stringutils.stript Onull ("D d dd") = "D d dd" Stringutils.striptonull ("dd") = "dd" 131 stringutils.striptonull ("dd") = "DD"

The difference between Isnotempty and Isnotblank in StringUtils "Java string null"

Related Article

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.