类 StringUtils

java.lang.Object
com.alibaba.nacos.common.utils.StringUtils

public class StringUtils extends Object
string util.
作者:
Nacos
  • 字段详细资料

  • 构造器详细资料

    • StringUtils

      public StringUtils()
  • 方法详细资料

    • newStringForUtf8

      public static String newStringForUtf8(byte[] bytes)
    • isBlank

      public static boolean isBlank(String str)
      Judge whether string is blank.
      参数:
      str - string
      返回:
      true if str is null, empty string or only blanks, otherwise false
    • isAllBlank

      public static boolean isAllBlank(String... strs)
      Judge whether all strings are blank.
      参数:
      strs - strings
      返回:
      true if all strings are blank, otherwise false
    • isNotBlank

      public static boolean isNotBlank(String str)
    • isNotEmpty

      public static boolean isNotEmpty(String str)
    • isEmpty

      public static boolean isEmpty(String str)
    • defaultIfEmpty

      public static String defaultIfEmpty(String str, String defaultStr)
    • equals

      public static boolean equals(String str1, String str2)
    • trim

      public static String trim(String str)
    • substringBetween

      public static String substringBetween(String str, String open, String close)
      Substring between two index.
      参数:
      str - string
      open - start index to sub
      close - end index to sub
      返回:
      substring
    • join

      public static String join(Collection collection, String separator)
      Join object with input separator.
      参数:
      collection - collection of objects need to join
      separator - separator
      返回:
      joined string
    • escapeJavaScript

      public static String escapeJavaScript(String str)
    • containsIgnoreCase

      public static boolean containsIgnoreCase(CharSequence str, CharSequence searchStr)
      Checks if CharSequence contains a search CharSequence irrespective of case, handling null. Case-insensitivity is defined as by String.equalsIgnoreCase(String).

      A null CharSequence will return false.

       StringUtils.contains(null, *) = false
       StringUtils.contains(*, null) = false
       StringUtils.contains("", "") = true
       StringUtils.contains("abc", "") = true
       StringUtils.contains("abc", "a") = true
       StringUtils.contains("abc", "z") = false
       StringUtils.contains("abc", "A") = true
       StringUtils.contains("abc", "Z") = false
       
      参数:
      str - the CharSequence to check, may be null
      searchStr - the CharSequence to find, may be null
      返回:
      true if the CharSequence contains the search CharSequence irrespective of case or false if not or null string input
      从以下版本开始:
      3.0 Changed signature from containsIgnoreCase(String, String) to containsIgnoreCase(CharSequence, CharSequence)
    • equalsIgnoreCase

      public static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2)

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

      nulls are handled without exceptions. Two null references are considered equal. Comparison is case insensitive.

       StringUtils.equalsIgnoreCase(null, null)   = true
       StringUtils.equalsIgnoreCase(null, "abc")  = false
       StringUtils.equalsIgnoreCase("abc", null)  = false
       StringUtils.equalsIgnoreCase("abc", "abc") = true
       StringUtils.equalsIgnoreCase("abc", "ABC") = true
       
      参数:
      str1 - the first CharSequence, may be null
      str2 - the second CharSequence, may be null
      返回:
      true if the CharSequence are equal, case insensitive, or both null
      从以下版本开始:
      3.0 Changed signature from equalsIgnoreCase(String, String) to equalsIgnoreCase(CharSequence, CharSequence)