Stringutils. isempty and stringutils. isblank usage

Source: Internet
Author: User
  1. The operation object of the stringutils method is Java. lang. string-type objects are complementary to the string-type operation method provided by JDK, and are null safe (that is, if the input parameter string is null, nullpointerexception is not thrown, but corresponding processing is performed, for example, if the input is null, the return value is also null. You can view the source code ).
  2. In addition to the constringutils, there are more than 130 methods in stringutils and they are all static, so we can call stringutils. XXX () in this way ()
  3. The following describes some common methods:
  4. 1. Public static Boolean isempty (string Str)
  5. Determines whether a string is null. If it is null, the standard is str = NULL or str. Length () = 0.
  6. The following is an example of stringutils determining whether it is null:
  7. Stringutils. isempty (null) = true
  8. Stringutils. isempty ("") = true
  9. Stringutils. isempty ("") = false // note that non-empty spaces are processed in stringutils.
  10. Stringutils. isempty ("") = false
  11. Stringutils. isempty ("Bob") = false
  12. Stringutils. isempty ("Bob") = false
  13. 2. Public static Boolean isnotempty (string Str)
  14. Determines whether a string is not null. It is equal! Isempty (string Str)
  15. The following is an example:
  16. Stringutils. isnotempty (null) = false
  17. Stringutils. isnotempty ("") = false
  18. Stringutils. isnotempty ("") = true
  19. Stringutils. isnotempty ("") = true
  20. Stringutils. isnotempty ("Bob") = true
  21. Stringutils. isnotempty ("Bob") = true
  22. 3. Public static Boolean isblank (string Str)
  23. Determines whether a string is null or has a length of 0 or is composed of whitespace.
  24. The following is an example:
  25. Stringutils. isblank (null) = true
  26. Stringutils. isblank ("") = true
  27. Stringutils. isblank ("") = true
  28. Stringutils. isblank ("") = true
  29. Stringutils. isblank ("\ t \ n \ f \ r") = true // For tabs, line breaks, page breaks, and carriage returns
  30. Stringutils. isblank () // both are blank characters
  31. Stringutils. isblank ("\ B") = false // "\ B" is the word boundary.
  32. Stringutils. isblank ("Bob") = false
  33. Stringutils. isblank ("Bob") = false
  34. 4. Public static Boolean isnotblank (string Str)
  35. Determines whether a string is not empty and its length is not 0. It cannot be composed of whitespace. It is equal! Isblank (string Str)
  36. The following is an example:
  37. Stringutils. isnotblank (null) = false
  38. Stringutils. isnotblank ("") = false
  39. Stringutils. isnotblank ("") = false
  40. Stringutils. isnotblank ("") = false
  41. Stringutils. isnotblank ("\ t \ n \ f \ r") = false
  42. Stringutils. isnotblank ("\ B") = true
  43. Stringutils. isnotblank ("Bob") = true
  44. Stringutils. isnotblank ("Bob") = true
  45. 5. Public static string trim (string Str)
  46. Removes the control character (char <= 32) at both ends of the string. If the input is null, null is returned.
  47. The following is an example:
  48. Stringutils. Trim (null) = NULL
  49. Stringutils. Trim ("") = ""
  50. Stringutils. Trim ("") = ""
  51. Stringutils. Trim ("\ B \ t \ n \ f \ r") = ""
  52. Stringutils. Trim ("\ n \ TSS \ B") = "SS"
  53. Stringutils. Trim ("d dd") = "d dd"
  54. Stringutils. Trim ("DD") = "DD"
  55. Stringutils. Trim ("DD") = "DD"
  56. 6. Public static string trimtonull (string Str)
  57. Removes the control character (char <= 32) at both ends of the string. If it is null or "", null is returned.
  58. The following is an example:
  59. Stringutils. trimtonull (null) = NULL
  60. Stringutils. trimtonull ("") = NULL
  61. Stringutils. trimtonull ("") = NULL
  62. Stringutils. trimtonull ("\ B \ t \ n \ f \ r") = NULL
  63. Stringutils. trimtonull ("\ n \ TSS \ B") = "SS"
  64. Stringutils. trimtonull ("d dd") = "d dd"
  65. Stringutils. trimtonull ("DD") = "DD"
  66. Stringutils. trimtonull ("DD") = "DD"
  67. 7. Public static string trimtoempty (string Str)
  68. Removes the control character (char <= 32) at both ends of the string. If it is null or "", "" is returned ""
  69. The following is an example:
  70. Stringutils. trimtoempty (null) = ""
  71. Stringutils. trimtoempty ("") = ""
  72. Stringutils. trimtoempty ("") = ""
  73. Stringutils. trimtoempty ("\ B \ t \ n \ f \ r") = ""
  74. Stringutils. trimtoempty ("\ n \ TSS \ B") = "SS"
  75. Stringutils. trimtoempty ("d dd") = "d dd"
  76. Stringutils. trimtoempty ("DD") = "DD"
  77. Stringutils. trimtoempty ("DD") = "DD"

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.