类 StringUtils


  • public class StringUtils
    extends java.lang.Object
    StringUtils. copy from apache common-lang3.
    作者:
    lin-mt
    • 字段概要

      字段 
      修饰符和类型 字段 说明
      static java.lang.String EMPTY
      The empty String "".
    • 构造器概要

      构造器 
      构造器 说明
      StringUtils()  
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static boolean equals​(java.lang.CharSequence cs1, java.lang.CharSequence cs2)
      Compares two CharSequences, returning true if they represent equal sequences of characters.
      static boolean isBlank​(java.lang.CharSequence cs)
      Checks if a CharSequence is whitespace, empty ("") or null.
      static boolean isEmpty​(java.lang.CharSequence cs)
      Checks if a CharSequence is empty ("") or null.
      static boolean regionMatches​(java.lang.CharSequence cs, boolean ignoreCase, int thisStart, java.lang.CharSequence substring, int start, int length)
      Green implementation of regionMatches.
      static java.lang.String trim​(java.lang.String str)
      Removes control characters (char <= 32) from both ends of this String, handling null by returning null.
      • 从类继承的方法 java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 字段详细资料

      • EMPTY

        public static final java.lang.String EMPTY
        The empty String "".
        从以下版本开始:
        2.0
        另请参阅:
        常量字段值
    • 构造器详细资料

      • StringUtils

        public StringUtils()
    • 方法详细资料

      • isEmpty

        public static boolean isEmpty​(java.lang.CharSequence cs)

        Checks if a CharSequence is empty ("") or null.

         StringUtils.isEmpty(null)      = true
         StringUtils.isEmpty("")        = true
         StringUtils.isEmpty(" ")       = false
         StringUtils.isEmpty("bob")     = false
         StringUtils.isEmpty("  bob  ") = false
         

        NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().

        参数:
        cs - the CharSequence to check, may be null
        返回:
        true if the CharSequence is empty or null
        从以下版本开始:
        3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence)
      • isBlank

        public static boolean isBlank​(java.lang.CharSequence cs)

        Checks if a CharSequence is whitespace, empty ("") or null.

         StringUtils.isBlank(null)      = true
         StringUtils.isBlank("")        = true
         StringUtils.isBlank(" ")       = true
         StringUtils.isBlank("bob")     = false
         StringUtils.isBlank("  bob  ") = false
         
        参数:
        cs - the CharSequence to check, may be null
        返回:
        true if the CharSequence is null, empty or whitespace
        从以下版本开始:
        2.0, 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
      • trim

        public static java.lang.String trim​(java.lang.String str)

        Removes control characters (char <= 32) from both ends of this String, handling null by returning null.

        The String is trimmed using String.trim(). Trim removes start and end characters <= 32.

         StringUtils.trim(null)          = null
         StringUtils.trim("")            = ""
         StringUtils.trim("     ")       = ""
         StringUtils.trim("abc")         = "abc"
         StringUtils.trim("    abc    ") = "abc"
         
        参数:
        str - the String to be trimmed, may be null
        返回:
        the trimmed string, null if null String input
      • equals

        public static boolean equals​(java.lang.CharSequence cs1,
                                     java.lang.CharSequence cs2)

        Compares two CharSequences, returning true if they represent equal sequences of characters.

        nulls are handled without exceptions. Two null references are considered to be equal. The comparison is case sensitive.

         StringUtils.equals(null, null)   = true
         StringUtils.equals(null, "abc")  = false
         StringUtils.equals("abc", null)  = false
         StringUtils.equals("abc", "abc") = true
         StringUtils.equals("abc", "ABC") = false
         
        参数:
        cs1 - the first CharSequence, may be null
        cs2 - the second CharSequence, may be null
        返回:
        true if the CharSequences are equal (case-sensitive), or both null
        从以下版本开始:
        3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
        另请参阅:
        Object.equals(Object)
      • regionMatches

        public static boolean regionMatches​(java.lang.CharSequence cs,
                                            boolean ignoreCase,
                                            int thisStart,
                                            java.lang.CharSequence substring,
                                            int start,
                                            int length)
        Green implementation of regionMatches.
        参数:
        cs - the CharSequence to be processed
        ignoreCase - whether or not to be case insensitive
        thisStart - the index to start on the cs CharSequence
        substring - the CharSequence to be looked for
        start - the index to start on the substring CharSequence
        length - character length of the region
        返回:
        whether the region matched