类 StringUtils

java.lang.Object
com.baidu.bjf.remoting.protobuf.utils.StringUtils

public class StringUtils extends Object
String utility class.
从以下版本开始:
1.2.5
作者:
xiemalin
  • 字段详细资料

  • 构造器详细资料

    • StringUtils

      public StringUtils()
  • 方法详细资料

    • endsWith

      public static boolean endsWith(String str, String suffix)

      Check if a String ends with a specified suffix.

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

       StringUtils.endsWith(null, null)      = true
       StringUtils.endsWith(null, "abcdef")  = false
       StringUtils.endsWith("def", null)     = false
       StringUtils.endsWith("def", "abcdef") = true
       StringUtils.endsWith("def", "ABCDEF") = false
       
      参数:
      str - the String to check, may be null
      suffix - the suffix to find, may be null
      返回:
      true if the String ends with the suffix, case sensitive, or both null
      从以下版本开始:
      2.4
      另请参阅:
    • endsWithIgnoreCase

      public static boolean endsWithIgnoreCase(String str, String suffix)

      Case insensitive check if a String ends with a specified suffix.

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

       StringUtils.endsWithIgnoreCase(null, null)      = true
       StringUtils.endsWithIgnoreCase(null, "abcdef")  = false
       StringUtils.endsWithIgnoreCase("def", null)     = false
       StringUtils.endsWithIgnoreCase("def", "abcdef") = true
       StringUtils.endsWithIgnoreCase("def", "ABCDEF") = false
       
      参数:
      str - the String to check, may be null
      suffix - the suffix to find, may be null
      返回:
      true if the String ends with the suffix, case insensitive, or both null
      从以下版本开始:
      2.4
      另请参阅:
    • removeEnd

      public static String removeEnd(String str, String remove)

      Removes a substring only if it is at the end of a source string, otherwise returns the source string.

      A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string.

       StringUtils.removeEnd(null, *)      = null
       StringUtils.removeEnd("", *)        = ""
       StringUtils.removeEnd(*, null)      = *
       StringUtils.removeEnd("www.domain.com", ".com.")  = "www.domain.com"
       StringUtils.removeEnd("www.domain.com", ".com")   = "www.domain"
       StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com"
       StringUtils.removeEnd("abc", "")    = "abc"
       
      参数:
      str - the source String to search, may be null
      remove - the String to search for and remove, may be null
      返回:
      the substring with the string removed if found, null if null String input
      从以下版本开始:
      2.1
    • removeEndIgnoreCase

      public static String removeEndIgnoreCase(String str, String remove)

      Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.

      A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string.

       StringUtils.removeEnd(null, *)      = null
       StringUtils.removeEnd("", *)        = ""
       StringUtils.removeEnd(*, null)      = *
       StringUtils.removeEnd("www.domain.com", ".com.")  = "www.domain.com."
       StringUtils.removeEnd("www.domain.com", ".com")   = "www.domain"
       StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com"
       StringUtils.removeEnd("abc", "")    = "abc"
       
      参数:
      str - the source String to search, may be null
      remove - the String to search for (case insensitive) and remove, may be null
      返回:
      the substring with the string removed if found, null if null String input
      从以下版本开始:
      2.4
    • isEmpty

      public static boolean isEmpty(String str)

      Checks if a String 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 String. That functionality is available in isBlank().

      参数:
      str - the String to check, may be null
      返回:
      true if the String is empty or null
    • removeStart

      public static String removeStart(String str, String remove)

      Removes a substring only if it is at the begining of a source string, otherwise returns the source string.

      A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string.

       StringUtils.removeStart(null, *)      = null
       StringUtils.removeStart("", *)        = ""
       StringUtils.removeStart(*, null)      = *
       StringUtils.removeStart("www.domain.com", "www.")   = "domain.com"
       StringUtils.removeStart("domain.com", "www.")       = "domain.com"
       StringUtils.removeStart("www.domain.com", "domain") = "www.domain.com"
       StringUtils.removeStart("abc", "")    = "abc"
       
      参数:
      str - the source String to search, may be null
      remove - the String to search for and remove, may be null
      返回:
      the substring with the string removed if found, null if null String input
      从以下版本开始:
      2.1
    • removeStartIgnoreCase

      public static String removeStartIgnoreCase(String str, String remove)

      Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.

      A null source string will return null. An empty ("") source string will return the empty string. A null search string will return the source string.

       StringUtils.removeStartIgnoreCase(null, *)      = null
       StringUtils.removeStartIgnoreCase("", *)        = ""
       StringUtils.removeStartIgnoreCase(*, null)      = *
       StringUtils.removeStartIgnoreCase("www.domain.com", "www.")   = "domain.com"
       StringUtils.removeStartIgnoreCase("www.domain.com", "WWW.")   = "domain.com"
       StringUtils.removeStartIgnoreCase("domain.com", "www.")       = "domain.com"
       StringUtils.removeStartIgnoreCase("www.domain.com", "domain") = "www.domain.com"
       StringUtils.removeStartIgnoreCase("abc", "")    = "abc"
       
      参数:
      str - the source String to search, may be null
      remove - the String to search for (case insensitive) and remove, may be null
      返回:
      the substring with the string removed if found, null if null String input
      从以下版本开始:
      2.4
    • startsWith

      public static boolean startsWith(String str, String prefix)

      Check if a String starts with a specified prefix.

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

       StringUtils.startsWith(null, null)      = true
       StringUtils.startsWith(null, "abcdef")  = false
       StringUtils.startsWith("abc", null)     = false
       StringUtils.startsWith("abc", "abcdef") = true
       StringUtils.startsWith("abc", "ABCDEF") = false
       
      参数:
      str - the String to check, may be null
      prefix - the prefix to find, may be null
      返回:
      true if the String starts with the prefix, case sensitive, or both null
      从以下版本开始:
      2.4
      另请参阅:
    • startsWithAny

      public static boolean startsWithAny(String string, String[] searchStrings)

      Check if a String starts with any of an array of specified strings.

       StringUtils.startsWithAny(null, null)      = false
       StringUtils.startsWithAny(null, new String[] {"abc"})  = false
       StringUtils.startsWithAny("abcxyz", null)     = false
       StringUtils.startsWithAny("abcxyz", new String[] {""}) = false
       StringUtils.startsWithAny("abcxyz", new String[] {"abc"}) = true
       StringUtils.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true
       
      参数:
      string - the String to check, may be null
      searchStrings - the Strings to find, may be null or empty
      返回:
      true if the String starts with any of the the prefixes, case insensitive, or both null
      从以下版本开始:
      2.5
      另请参阅:
    • startsWithIgnoreCase

      public static boolean startsWithIgnoreCase(String str, String prefix)

      Case insensitive check if a String starts with a specified prefix.

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

       StringUtils.startsWithIgnoreCase(null, null)      = true
       StringUtils.startsWithIgnoreCase(null, "abcdef")  = false
       StringUtils.startsWithIgnoreCase("abc", null)     = false
       StringUtils.startsWithIgnoreCase("abc", "abcdef") = true
       StringUtils.startsWithIgnoreCase("abc", "ABCDEF") = true
       
      参数:
      str - the String to check, may be null
      prefix - the prefix to find, may be null
      返回:
      true if the String starts with the prefix, case insensitive, or both null
      从以下版本开始:
      2.4
      另请参阅:
    • substringBefore

      public static String substringBefore(String str, String separator)

      Gets the substring before the first occurrence of a separator. The separator is not returned.

      A null string input will return null. An empty ("") string input will return the empty string. A null separator will return the input string.

       StringUtils.substringBefore(null, *)      = null
       StringUtils.substringBefore("", *)        = ""
       StringUtils.substringBefore("abc", "a")   = ""
       StringUtils.substringBefore("abcba", "b") = "a"
       StringUtils.substringBefore("abc", "c")   = "ab"
       StringUtils.substringBefore("abc", "d")   = "abc"
       StringUtils.substringBefore("abc", "")    = ""
       StringUtils.substringBefore("abc", null)  = "abc"
       
      参数:
      str - the String to get a substring from, may be null
      separator - the String to search for, may be null
      返回:
      the substring before the first occurrence of the separator, null if null String input
      从以下版本开始:
      2.0
    • substringBeforeLast

      public static String substringBeforeLast(String str, String separator)

      Gets the substring before the last occurrence of a separator. The separator is not returned.

      A null string input will return null. An empty ("") string input will return the empty string. An empty or null separator will return the input string.

       StringUtils.substringBeforeLast(null, *)      = null
       StringUtils.substringBeforeLast("", *)        = ""
       StringUtils.substringBeforeLast("abcba", "b") = "abc"
       StringUtils.substringBeforeLast("abc", "c")   = "ab"
       StringUtils.substringBeforeLast("a", "a")     = ""
       StringUtils.substringBeforeLast("a", "z")     = "a"
       StringUtils.substringBeforeLast("a", null)    = "a"
       StringUtils.substringBeforeLast("a", "")      = "a"
       
      参数:
      str - the String to get a substring from, may be null
      separator - the String to search for, may be null
      返回:
      the substring before the last occurrence of the separator, null if null String input
      从以下版本开始:
      2.0
    • substringAfterLast

      public static String substringAfterLast(String str, String separator)

      Gets the substring after the last occurrence of a separator. The separator is not returned.

      A null string input will return null. An empty ("") string input will return the empty string. An empty or null separator will return the empty string if the input string is not null.

       StringUtils.substringAfterLast(null, *)      = null
       StringUtils.substringAfterLast("", *)        = ""
       StringUtils.substringAfterLast(*, "")        = ""
       StringUtils.substringAfterLast(*, null)      = ""
       StringUtils.substringAfterLast("abc", "a")   = "bc"
       StringUtils.substringAfterLast("abcba", "b") = "a"
       StringUtils.substringAfterLast("abc", "c")   = ""
       StringUtils.substringAfterLast("a", "a")     = ""
       StringUtils.substringAfterLast("a", "z")     = ""
       
      参数:
      str - the String to get a substring from, may be null
      separator - the String to search for, may be null
      返回:
      the substring after the last occurrence of the separator, null if null String input
      从以下版本开始:
      2.0
    • capitalize

      public static String capitalize(String str)

      Capitalizes a String changing the first letter to title case as per Character.toTitleCase(char). No other letters are changed.

      For a word based algorithm, see WordUtils#capitalize(String). A null input String returns null.

       StringUtils.capitalize(null)  = null
       StringUtils.capitalize("")    = ""
       StringUtils.capitalize("cat") = "Cat"
       StringUtils.capitalize("cAt") = "CAt"
       
      参数:
      str - the String to capitalize, may be null
      返回:
      the capitalized String, null if null String input
      从以下版本开始:
      2.0
      另请参阅:
    • escapeJava

      public static String escapeJava(String str)

      Escapes the characters in a String using Java String rules.

      Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)

      So a tab becomes the characters '\\' and 't'.

      The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote must be escaped.

      Example:

       input string: He didn't say, "Stop!"
       output string: He didn't say, \"Stop!\"
       

      参数:
      str - String to escape values in, may be null
      返回:
      String with escaped values, null if null string input
    • escapeJava

      public static void escapeJava(Writer out, String str) throws IOException

      Escapes the characters in a String using Java String rules to a Writer.

      A null string input has no effect.

      参数:
      out - Writer to write escaped string into
      str - String to escape values in, may be null
      抛出:
      IllegalArgumentException - if the Writer is null
      IOException - if error occurs on underlying Writer
      另请参阅:
    • unescapeJava

      public static String unescapeJava(String str)

      Unescapes any Java literals found in the String. For example, it will turn a sequence of '\' and 'n' into a newline character, unless the '\' is preceded by another '\'.

      参数:
      str - the String to unescape, may be null
      返回:
      a new unescaped String, null if null string input
    • unescapeJava

      public static void unescapeJava(Writer out, String str) throws IOException

      Unescapes any Java literals found in the String to a Writer.

      For example, it will turn a sequence of '\' and 'n' into a newline character, unless the '\' is preceded by another '\'.

      A null string input has no effect.

      参数:
      out - the Writer used to output unescaped characters
      str - the String to unescape, may be null
      抛出:
      IllegalArgumentException - if the Writer is null
      IOException - if error occurs on underlying Writer
    • split

      public static String[] split(String str)

      Splits the provided text into an array, using whitespace as the separator. Whitespace is defined by Character.isWhitespace(char).

      The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.

      A null input String returns null.

       StringUtils.split(null)       = null
       StringUtils.split("")         = []
       StringUtils.split("abc def")  = ["abc", "def"]
       StringUtils.split("abc  def") = ["abc", "def"]
       StringUtils.split(" abc ")    = ["abc"]
       
      参数:
      str - the String to parse, may be null
      返回:
      an array of parsed Strings, null if null String input
    • split

      public static String[] split(String str, char separatorChar)

      Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer.

      The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.

      A null input String returns null.

       StringUtils.split(null, *)         = null
       StringUtils.split("", *)           = []
       StringUtils.split("a.b.c", '.')    = ["a", "b", "c"]
       StringUtils.split("a..b.c", '.')   = ["a", "b", "c"]
       StringUtils.split("a:b:c", '.')    = ["a:b:c"]
       StringUtils.split("a b c", ' ')    = ["a", "b", "c"]
       
      参数:
      str - the String to parse, may be null
      separatorChar - the character used as the delimiter
      返回:
      an array of parsed Strings, null if null String input
      从以下版本开始:
      2.0
    • split

      public static String[] split(String str, String separatorChars)

      Splits the provided text into an array, separators specified. This is an alternative to using StringTokenizer.

      The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.

      A null input String returns null. A null separatorChars splits on whitespace.

       StringUtils.split(null, *)         = null
       StringUtils.split("", *)           = []
       StringUtils.split("abc def", null) = ["abc", "def"]
       StringUtils.split("abc def", " ")  = ["abc", "def"]
       StringUtils.split("abc  def", " ") = ["abc", "def"]
       StringUtils.split("ab:cd:ef", ":") = ["ab", "cd", "ef"]
       
      参数:
      str - the String to parse, may be null
      separatorChars - the characters used as the delimiters, null splits on whitespace
      返回:
      an array of parsed Strings, null if null String input
    • split

      public static String[] split(String str, String separatorChars, int max)

      Splits the provided text into an array with a maximum length, separators specified.

      The separator is not included in the returned String array. Adjacent separators are treated as one separator.

      A null input String returns null. A null separatorChars splits on whitespace.

      If more than max delimited substrings are found, the last returned string includes all characters after the first max - 1 returned strings (including separator characters).

       StringUtils.split(null, *, *)            = null
       StringUtils.split("", *, *)              = []
       StringUtils.split("ab de fg", null, 0)   = ["ab", "cd", "ef"]
       StringUtils.split("ab   de fg", null, 0) = ["ab", "cd", "ef"]
       StringUtils.split("ab:cd:ef", ":", 0)    = ["ab", "cd", "ef"]
       StringUtils.split("ab:cd:ef", ":", 2)    = ["ab", "cd:ef"]
       
      参数:
      str - the String to parse, may be null
      separatorChars - the characters used as the delimiters, null splits on whitespace
      max - the maximum number of elements to include in the array. A zero or negative value implies no limit
      返回:
      an array of parsed Strings, null if null String input
    • splitByWholeSeparator

      public static String[] splitByWholeSeparator(String str, String separator)

      Splits the provided text into an array, separator string specified.

      The separator(s) will not be included in the returned String array. Adjacent separators are treated as one separator.

      A null input String returns null. A null separator splits on whitespace.

       StringUtils.splitByWholeSeparator(null, *)               = null
       StringUtils.splitByWholeSeparator("", *)                 = []
       StringUtils.splitByWholeSeparator("ab de fg", null)      = ["ab", "de", "fg"]
       StringUtils.splitByWholeSeparator("ab   de fg", null)    = ["ab", "de", "fg"]
       StringUtils.splitByWholeSeparator("ab:cd:ef", ":")       = ["ab", "cd", "ef"]
       StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-") = ["ab", "cd", "ef"]
       
      参数:
      str - the String to parse, may be null
      separator - String containing the String to be used as a delimiter, null splits on whitespace
      返回:
      an array of parsed Strings, null if null String was input
    • splitByWholeSeparator

      public static String[] splitByWholeSeparator(String str, String separator, int max)

      Splits the provided text into an array, separator string specified. Returns a maximum of max substrings.

      The separator(s) will not be included in the returned String array. Adjacent separators are treated as one separator.

      A null input String returns null. A null separator splits on whitespace.

       StringUtils.splitByWholeSeparator(null, *, *)               = null
       StringUtils.splitByWholeSeparator("", *, *)                 = []
       StringUtils.splitByWholeSeparator("ab de fg", null, 0)      = ["ab", "de", "fg"]
       StringUtils.splitByWholeSeparator("ab   de fg", null, 0)    = ["ab", "de", "fg"]
       StringUtils.splitByWholeSeparator("ab:cd:ef", ":", 2)       = ["ab", "cd:ef"]
       StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", 5) = ["ab", "cd", "ef"]
       StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", 2) = ["ab", "cd-!-ef"]
       
      参数:
      str - the String to parse, may be null
      separator - String containing the String to be used as a delimiter, null splits on whitespace
      max - the maximum number of elements to include in the returned array. A zero or negative value implies no limit.
      返回:
      an array of parsed Strings, null if null String was input
    • splitByWholeSeparatorPreserveAllTokens

      public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator)

      Splits the provided text into an array, separator string specified.

      The separator is not included in the returned String array. Adjacent separators are treated as separators for empty tokens. For more control over the split use the StrTokenizer class.

      A null input String returns null. A null separator splits on whitespace.

       StringUtils.splitByWholeSeparatorPreserveAllTokens(null, *)               = null
       StringUtils.splitByWholeSeparatorPreserveAllTokens("", *)                 = []
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null)      = ["ab", "de", "fg"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab   de fg", null)    = ["ab", "", "", "de", "fg"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab:cd:ef", ":")       = ["ab", "cd", "ef"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-") = ["ab", "cd", "ef"]
       
      参数:
      str - the String to parse, may be null
      separator - String containing the String to be used as a delimiter, null splits on whitespace
      返回:
      an array of parsed Strings, null if null String was input
      从以下版本开始:
      2.4
    • splitByWholeSeparatorPreserveAllTokens

      public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max)

      Splits the provided text into an array, separator string specified. Returns a maximum of max substrings.

      The separator is not included in the returned String array. Adjacent separators are treated as separators for empty tokens. For more control over the split use the StrTokenizer class.

      A null input String returns null. A null separator splits on whitespace.

       StringUtils.splitByWholeSeparatorPreserveAllTokens(null, *, *)               = null
       StringUtils.splitByWholeSeparatorPreserveAllTokens("", *, *)                 = []
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null, 0)      = ["ab", "de", "fg"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab   de fg", null, 0)    = ["ab", "", "", "de", "fg"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab:cd:ef", ":", 2)       = ["ab", "cd:ef"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-", 5) = ["ab", "cd", "ef"]
       StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-", 2) = ["ab", "cd-!-ef"]
       
      参数:
      str - the String to parse, may be null
      separator - String containing the String to be used as a delimiter, null splits on whitespace
      max - the maximum number of elements to include in the returned array. A zero or negative value implies no limit.
      返回:
      an array of parsed Strings, null if null String was input
      从以下版本开始:
      2.4
    • escapeBytes

      public static String escapeBytes(byte[] input)
      Like #escapeBytes(ByteString), but used for byte array.
    • toInt

      public static int toInt(String str)

      Convert a String to an int, returning zero if the conversion fails.

      If the string is null, zero is returned.

         NumberUtils.toInt(null) = 0
         NumberUtils.toInt("")   = 0
         NumberUtils.toInt("1")  = 1
       
      参数:
      str - the string to convert, may be null
      返回:
      the int represented by the string, or zero if conversion fails
      从以下版本开始:
      2.1
    • stringToInt

      public static int stringToInt(String str, int defaultValue)
      已过时。
      Use toInt(String, int) This method will be removed in Commons Lang 3.0

      Convert a String to an int, returning a default value if the conversion fails.

      If the string is null, the default value is returned.

         NumberUtils.stringToInt(null, 1) = 1
         NumberUtils.stringToInt("", 1)   = 1
         NumberUtils.stringToInt("1", 0)  = 1
       
      参数:
      str - the string to convert, may be null
      defaultValue - the default value
      返回:
      the int represented by the string, or the default if conversion fails
    • toInt

      public static int toInt(String str, int defaultValue)

      Convert a String to an int, returning a default value if the conversion fails.

      If the string is null, the default value is returned.

         NumberUtils.toInt(null, 1) = 1
         NumberUtils.toInt("", 1)   = 1
         NumberUtils.toInt("1", 0)  = 1
       
      参数:
      str - the string to convert, may be null
      defaultValue - the default value
      返回:
      the int represented by the string, or the default if conversion fails
      从以下版本开始:
      2.1
    • toLong

      public static long toLong(String str)

      Convert a String to an long, returning a default value if the conversion fails.

      If the string is null, the default value is returned.

         NumberUtils.toLong(null) = 0
         NumberUtils.toLong("")   = 0
         NumberUtils.toLong("1")  = 1
       
      参数:
      str - the string to convert, may be null
      返回:
      the long represented by the string, or the default if conversion fails
      从以下版本开始:
      2.1
    • toLong

      public static long toLong(String str, long defaultValue)

      Convert a String to an long, returning a default value if the conversion fails.

      If the string is null, the default value is returned.

         NumberUtils.toLong(null, 1) = 1
         NumberUtils.toLong("", 1)   = 1
         NumberUtils.toLong("1", 0)  = 1
       
      参数:
      str - the string to convert, may be null
      defaultValue - the default value
      返回:
      the long represented by the string, or the default if conversion fails
      从以下版本开始:
      2.1
    • trimToEmpty

      public static String trimToEmpty(String str)

      Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is null.

      The String is trimmed using String.trim(). Trim removes start and end characters <= 32. To strip whitespace use #stripToEmpty(String).

       StringUtils.trimToEmpty(null)          = ""
       StringUtils.trimToEmpty("")            = ""
       StringUtils.trimToEmpty("     ")       = ""
       StringUtils.trimToEmpty("abc")         = "abc"
       StringUtils.trimToEmpty("    abc    ") = "abc"
       
      参数:
      str - the String to be trimmed, may be null
      返回:
      the trimmed String, or an empty String if null input
      从以下版本开始:
      2.0
    • uncapitalize

      public static String uncapitalize(String str)

      Uncapitalizes a String, changing the first character to lower case as per Character.toLowerCase(int). No other characters are changed.

      For a word based algorithm, see org.apache.commons.lang3.text.WordUtils#uncapitalize(String). A null input String returns null.

       StringUtils.uncapitalize(null)  = null
       StringUtils.uncapitalize("")    = ""
       StringUtils.uncapitalize("cat") = "cat"
       StringUtils.uncapitalize("Cat") = "cat"
       StringUtils.uncapitalize("CAT") = "cAT"
       
      参数:
      str - the String to uncapitalize, may be null
      返回:
      the uncapitalized String, null if null String input
      从以下版本开始:
      2.0
      另请参阅:
    • toLowerCase

      public static String toLowerCase(String str)
      To lower case.
      参数:
      str - the str
      返回:
      the string
    • isEmpty

      public static boolean isEmpty(Object[] array)

      Checks if an array of Objects is empty or null.

      参数:
      array - the array to test
      返回:
      true if the array is empty or null
      从以下版本开始:
      2.1