程序包 com.sh.util

类 StringUtil

java.lang.Object
com.sh.util.StringUtil

public abstract class StringUtil extends Object
Description: 字符串工具类 Title:首亨软件 - CRM、TSS、ERP等信息化管理软件
  • 构造器详细资料

    • StringUtil

      public StringUtil()
  • 方法详细资料

    • isStringHasWideChar

      public static boolean isStringHasWideChar(String s)
      如果至少有一个汉字,则返回真
      参数:
      s - 字符串
      返回:
      true|false
    • getWideCharCount

      public static int getWideCharCount(String s)
      字符串中包含的中文字符数
      参数:
      s - 字符串
      返回:
      int
    • sizeof

      public static int sizeof(String str)
      获取字符串占用字节数
      参数:
      str - String
      返回:
      int
    • getArgList

      public static List<String> getArgList(String... args)
      将给定的参数组合成List对象
      参数:
      args - 可变参数
      返回:
      List
    • isNotBlank

      public static boolean isNotBlank(String str)
      是否非空字符串
      参数:
      str - String
      返回:
      boolean
    • isBlank

      public static boolean isBlank(String str)
      是否空字符串
      参数:
      str - String
      返回:
      boolean
    • String2InputStream

      public static InputStream String2InputStream(String str)
      将字符串转化为InputStream流对象
      参数:
      str - String
      返回:
      InputStream
    • inputStream2String

      public static String inputStream2String(InputStream is)
    • inputStream2String

      public static String inputStream2String(InputStream is, String addEnter, String charset)
      将字符中流转化为字符串
      参数:
      is - InputStream
      addEnter - 行后面添加换行标识
      charset - String
      返回:
      String
    • split

      public static List<String> split(String text, char separator)
      取代String.split (正则表达式) 效率提高1倍,同时避免 | 等字符引起的分隔问题
      参数:
      text - String
      separator - char
      返回:
      List
    • convert2Double

      public static Double convert2Double(String str)
      将字符串转化为Double对象
      参数:
      str - String
      返回:
      Double
    • convert2Integer

      public static Integer convert2Integer(String str)
      将字符串转化为整形对象
      参数:
      str - String
      返回:
      Integer
    • convert2Long

      public static Long convert2Long(String str)
    • convertNull2Empty

      public static String convertNull2Empty(String str)
      判断字符串是否为空
      参数:
      str - String
      返回:
      String
    • convertNull2Default

      public static String convertNull2Default(String str, String defaultValue)
    • hasUnicodeStr

      public static boolean hasUnicodeStr(String str)
      查找字符串是否存在中文字符
      参数:
      str - String
      返回:
      boolean
    • unicodeCount

      public static int unicodeCount(String str)
      获取字符串中包括的字符数
      参数:
      str - String
      返回:
      int
    • convertUnicodeToString

      public static String convertUnicodeToString(String input)
      将unicode字符串转为标准中文
      参数:
      input -
      返回:
    • checkSequence

      public static boolean checkSequence(String str)
      判断输入是否有效
      参数:
      str - String
      返回:
      boolean
    • isDigit

      public static boolean isDigit(String str)
      判断是否数字
      参数:
      str - String
      返回:
      boolean
    • isCharacter

      public static boolean isCharacter(String str)
      判断是否全为字母
      参数:
      str - String
      返回:
      boolean
    • lpad

      public static String lpad(String str, int size, String padStr)
      如果str的长度小于size,则会在字符串的左边增加padStr字符串
      参数:
      str - 源字符串
      size - 最小长度
      padStr - 填充字符串
      返回:
      String
    • lpad

      public static String lpad(String str, int size, char padStr)
      如果str的长度小于size,则会在字符串的左边增加padStr字符串
      参数:
      str - 源字符串
      size - 最小长度
      padStr - 填充字符
      返回:
      String
    • rpad

      public static String rpad(String str, int size, String padStr)
      如果str的长度小于size,则会在字符串的右边增加padStr字符串
      参数:
      str - 源字符串
      size - 最小长度
      padStr - 填充字符串
      返回:
      String
    • rpad

      public static String rpad(String str, int size, char padStr)
      如果str的长度小于size,则会在字符串的右边增加padStr字符串
      参数:
      str - 源字符串
      size - 最小长度
      padStr - 填充字符
      返回:
      String
    • trimAll

      public static String trimAll(String str)
      清除所有空格
      参数:
      str - String
      返回:
      String
    • timeFormat

      public static String timeFormat(String sec)
      格式化时间
      参数:
      sec - 时间字符串(单位:秒)
      返回:
      00:00:00
    • timeFormat

      public static String timeFormat(Double sec)
      格式化时间
      参数:
      sec - 时间(单位:秒)
      返回:
      00:00:00
    • timeFormat

      public static String timeFormat(int sec)
      格式化时间
      参数:
      sec - 时间(单位:秒)
      返回:
      00:00:00
    • timeFormat

      public static String timeFormat(long time)
      格式化时间
      参数:
      time - 时间(单位:秒)
      返回:
      00:00:00
    • timeFormatFull

      public static String timeFormatFull(long time)
    • format

      public static String format(String str, Object... param)
      格式化字符串
      参数:
      str - 形如:{0} weighed {2,number,##.#} kg on {1,date}
      param - 参数,形如: new Object[] {"Petunia",new java.util.Date(),new Double(13.685)};
      返回:
      如:Petunia weighed 13.7 kg on Dec 5, 2004
    • replaceString

      public static String replaceString(String source, String tag, String value)
      将指定字符串中的标记用相应的字符串替换掉
      参数:
      source - 需要替换的字符串
      tag - 标记
      value - 替换值
      返回:
      相关标记被替换的字符串
    • isMessyCode

      public static boolean isMessyCode(String strName)
      判断字符是否乱码
      参数:
      strName - 待检查字符串
      返回:
      boolean
    • isChinese

      public static boolean isChinese(char c)
      字符是否为汉字
      参数:
      c - char
      返回:
      boolean
    • isCharacterOrDigit

      public static boolean isCharacterOrDigit(String str)
      判断字符串是否为数字或字母
      参数:
      str -
      返回:
    • encodeAES

      public static String encodeAES(String str) throws Exception
      加密字符串
      参数:
      str - String
      返回:
      String
      抛出:
      Exception - Exception
    • decodeAES

      public static String decodeAES(String estr) throws Exception
      解密字符串
      参数:
      estr - String
      返回:
      String
      抛出:
      Exception - Exception
    • encodeCharacter

      public static String encodeCharacter(String str)
    • decodeCharacter

      public static String decodeCharacter(String str)
    • decorateStringLikeArray

      public static String decorateStringLikeArray(String str, String left, String right, String regex)
      修饰字符串
      参数:
      str - 待修饰字符串,如:01,02,03
      left - 左边填充值
      right - 右边填充值,为空是同左边
      regex - 间隔值,为空时默认英文逗号
      返回:
      修饰后的值,如:'01','02','03'
    • decorateStringLikeArray

      public static String decorateStringLikeArray(String[] array, String left, String right, String regex)
    • decorateStringLikeArray

      public static String decorateStringLikeArray(String str, String left)
      修饰字符串
      参数:
      str - 待修饰字符串,如:01,02,03
      left - 左边填充值
      返回:
      修饰后的值,如:'01','02','03'
    • decorateStringLikeArray

      public static String decorateStringLikeArray(String[] str, String left)
    • stringifyException

      public static String stringifyException(Throwable e)
      将堆栈里的数据转化为字符串
      参数:
      e - 堆栈
      返回:
      String
    • arrayToString

      public static String arrayToString(String[] strs, String separator, String firstLastPrefix)
      数组转化为字符串
      参数:
      strs - 数组
      separator - 中间分隔符 默认逗号
      firstLastPrefix - 每项中前后值 默认为单引号
      返回:
      arrayToString(new String[]{"a","b","c"},",","'") 如:[a,b,c] 转化为 'a','b','c'
    • arrayToString

      public static String arrayToString(String[] strs)
    • byteToHexString

      public static String byteToHexString(byte[] bytes, int start, int end)
      将byte数据转化为16进制字符串
      参数:
      bytes - 数组
      start - 开始位置
      end - 结束位置
      返回:
      String
    • byteToHexString

      public static String byteToHexString(byte[] bytes)
      将byte转化为16进制
      参数:
      bytes - byte[]
      返回:
      String
    • hexStringToByte

      public static byte[] hexStringToByte(String hex)
      将16进制的字符串还原为byte数组
      参数:
      hex - 16进制字符串
      返回:
      byte[]
    • nameBeautify

      public static String nameBeautify(String str)
      命名美化,仅支持将_去掉并将下一个单词转化为首字母大写
      参数:
      str - user_id
      返回:
      userId
    • equals

      public static boolean equals(String str1, String str2)
      判断两个字符串是否相等,包括同时为null
      参数:
      str1 -
      str2 -
      返回:
    • escapeHTML

      public static String escapeHTML(String string)
      Escapes HTML Special characters present in the string.
      参数:
      string - String
      返回:
      HTML Escaped String representation
    • getStackTrace

      public static String getStackTrace(Thread t)
      获取指定线程中的堆栈信息
      参数:
      t - Thread
      返回:
      String
    • getLineSeparator

      public static String getLineSeparator()
    • cutContent

      public static String cutContent(String str, int len)
      判断字符串是否超过指定长度的中文字符,超出则截取字符串返回,如果需要截取,则以...结尾
      参数:
      str - 待判断的字符串
      len - 中文字符个数
      返回:
      String
    • cutContent

      public static String cutContent(String str, int len, String end)
      判断字符串是否超过指定长度的中文字符,超出则截取字符串返回
      参数:
      str - 待判断的字符串
      len - 中文字符个数
      end - 结尾符,默认:...
      返回:
      String
    • getGUID

      public static String getGUID()
    • isEmpty

      public static boolean isEmpty(Object str)
    • isEmpty

      public static boolean isEmpty(String str)
    • isNotEmpty

      public static boolean isNotEmpty(String str)
    • hasLength

      public static boolean hasLength(CharSequence str)
    • hasLength

      public static boolean hasLength(String str)
      Check that the given String is neither null nor of length 0.

      Note: this method returns true for a String that purely consists of whitespace.

      参数:
      str - the String to check (may be null)
      返回:
      true if the String is not null and has length
      另请参阅:
    • hasText

      public static boolean hasText(CharSequence str)
    • hasText

      public static boolean hasText(String str)
      Check whether the given String contains actual text.

      More specifically, this method returns true if the String is not null, its length is greater than 0, and it contains at least one non-whitespace character.

      参数:
      str - the String to check (may be null)
      返回:
      true if the String is not null, its length is greater than 0, and it does not contain whitespace only
      另请参阅:
    • containsWhitespace

      public static boolean containsWhitespace(CharSequence str)
      Check whether the given CharSequence contains any whitespace characters.
      参数:
      str - the CharSequence to check (may be null)
      返回:
      true if the CharSequence is not empty and contains at least 1 whitespace character
      另请参阅:
    • containsWhitespace

      public static boolean containsWhitespace(String str)
      Check whether the given String contains any whitespace characters.
      参数:
      str - the String to check (may be null)
      返回:
      true if the String is not empty and contains at least 1 whitespace character
      另请参阅:
    • trimWhitespace

      public static String trimWhitespace(String str)
      Trim leading and trailing whitespace from the given String.
      参数:
      str - the String to check
      返回:
      the trimmed String
      另请参阅:
    • trimAllWhitespace

      public static String trimAllWhitespace(String str)
      Trim all whitespace from the given String: leading, trailing, and in between characters.
      参数:
      str - the String to check
      返回:
      the trimmed String
      另请参阅:
    • trimLeadingWhitespace

      public static String trimLeadingWhitespace(String str)
      Trim leading whitespace from the given String.
      参数:
      str - the String to check
      返回:
      the trimmed String
      另请参阅:
    • trimTrailingWhitespace

      public static String trimTrailingWhitespace(String str)
      Trim trailing whitespace from the given String.
      参数:
      str - the String to check
      返回:
      the trimmed String
      另请参阅:
    • trimLeadingCharacter

      public static String trimLeadingCharacter(String str, char leadingCharacter)
      Trim all occurrences of the supplied leading character from the given String.
      参数:
      str - the String to check
      leadingCharacter - the leading character to be trimmed
      返回:
      the trimmed String
    • trimTrailingCharacter

      public static String trimTrailingCharacter(String str, char trailingCharacter)
      Trim all occurrences of the supplied trailing character from the given String.
      参数:
      str - the String to check
      trailingCharacter - the trailing character to be trimmed
      返回:
      the trimmed String
    • startsWithIgnoreCase

      public static boolean startsWithIgnoreCase(String str, String prefix)
      Test if the given String starts with the specified prefix, ignoring upper/lower case.
      参数:
      str - the String to check
      prefix - the prefix to look for
      返回:
      boolean
      另请参阅:
    • endsWithIgnoreCase

      public static boolean endsWithIgnoreCase(String str, String suffix)
      Test if the given String ends with the specified suffix, ignoring upper/lower case.
      参数:
      str - the String to check
      suffix - the suffix to look for
      返回:
      boolean
      另请参阅:
    • substringMatch

      public static boolean substringMatch(CharSequence str, int index, CharSequence substring)
      Test whether the given string matches the given substring at the given index.
      参数:
      str - the original string (or StringBuilder)
      index - the index in the original string to start matching against
      substring - the substring to match at the given index
      返回:
      boolean
    • countOccurrencesOf

      public static int countOccurrencesOf(String str, String sub)
      Count the occurrences of the substring sub in string str.
      参数:
      str - string to search in
      sub - string to search for
      返回:
      int
    • replace

      public static String replace(String inString, String oldPattern, String newPattern)
      Replace all occurrences of a substring within a string with another string.
      参数:
      inString - String to examine
      oldPattern - String to replace
      newPattern - String to insert
      返回:
      a String with the replacements
    • delete

      public static String delete(String inString, String pattern)
      Delete all occurrences of the given substring.
      参数:
      inString - the original String
      pattern - the pattern to delete all occurrences of
      返回:
      the resulting String
    • deleteAny

      public static String deleteAny(String inString, String charsToDelete)
      Delete any character in a given String.
      参数:
      inString - the original String
      charsToDelete - a set of characters to delete. E.g. "az\n" will delete 'a's, 'z's and new lines.
      返回:
      the resulting String
    • quote

      public static String quote(String str)
      Quote the given String with single quotes.
      参数:
      str - the input String (e.g. "myString")
      返回:
      the quoted String (e.g. "'myString'"), or null if the input was null
    • quoteIfString

      public static Object quoteIfString(Object obj)
      Turn the given Object into a String with single quotes if it is a String; keeping the Object as-is else.
      参数:
      obj - the input Object (e.g. "myString")
      返回:
      the quoted String (e.g. "'myString'"), or the input object as-is if not a String
    • unqualify

      public static String unqualify(String qualifiedName)
      Unqualify a string qualified by a '.' dot character. For example, "this.name.is.qualified", returns "qualified".
      参数:
      qualifiedName - the qualified name
      返回:
      String
    • unqualify

      public static String unqualify(String qualifiedName, char separator)
      Unqualify a string qualified by a separator character. For example, "this:name:is:qualified" returns "qualified" if using a ':' separator.
      参数:
      qualifiedName - the qualified name
      separator - the separator
      返回:
      String
    • capitalize

      public static String capitalize(String str)
      Capitalize a String, changing the first letter to upper case as per Character.toUpperCase(char). No other letters are changed.
      参数:
      str - the String to capitalize
      返回:
      the capitalized String
    • uncapitalize

      public static String uncapitalize(String str)
      Uncapitalize a String, changing the first letter to lower case as per Character.toLowerCase(char). No other letters are changed.
      参数:
      str - the String to uncapitalize
      返回:
      the uncapitalized String
    • getFilename

      public static String getFilename(String path)
      Extract the filename from the given Java resource path, e.g. "mypath/myfile.txt" -> "myfile.txt".
      参数:
      path - the file path (may be null)
      返回:
      the extracted filename, or null if none
    • getFilenameExtension

      public static String getFilenameExtension(String path)
      Extract the filename extension from the given Java resource path,
      参数:
      path - the file path (may be null)
      返回:
      the extracted filename extension, or null if none
    • stripFilenameExtension

      public static String stripFilenameExtension(String path)
      Strip the filename extension from the given Java resource path,
      参数:
      path - the file path
      返回:
      the path with stripped filename extension
    • applyRelativePath

      public static String applyRelativePath(String path, String relativePath)
      Apply the given relative path to the given Java resource path, assuming standard Java folder separation (i.e. "/" separators).
      参数:
      path - the path to start from (usually a full file path)
      relativePath - the relative path to apply (relative to the full file path above)
      返回:
      the full file path that results from applying the relative path
    • cleanPath

      public static String cleanPath(String path)
      Normalize the path by suppressing sequences like "path/.." and inner simple dots.

      The result is convenient for path comparison. For other uses, notice that Windows separators ("\") are replaced by simple slashes.

      参数:
      path - the original path
      返回:
      the normalized path
    • pathEquals

      public static boolean pathEquals(String path1, String path2)
      Compare two paths after normalization of them.
      参数:
      path1 - first path for comparison
      path2 - second path for comparison
      返回:
      whether the two paths are equivalent after normalization
    • parseLocaleString

      public static Locale parseLocaleString(String localeString)
      Parse the given localeString value into a Locale.

      This is the inverse operation of Locale's toString.

      参数:
      localeString - the locale String, following Locale's toString() format ("en", "en_UK", etc); also accepts spaces as separators, as an alternative to underscores
      返回:
      a corresponding Locale instance, or null if none
      抛出:
      IllegalArgumentException - in case of an invalid locale specification
    • toLanguageTag

      public static String toLanguageTag(Locale locale)
      Determine the RFC 3066 compliant language tag, as used for the HTTP "Accept-Language" header.
      参数:
      locale - the Locale to transform to a language tag
      返回:
      the RFC 3066 compliant language tag as String
    • parseTimeZoneString

      public static TimeZone parseTimeZoneString(String timeZoneString)
      Parse the given timeZoneString value into a TimeZone.
      参数:
      timeZoneString - the time zone String, following TimeZone.getTimeZone(String) but throwing IllegalArgumentException in case of an invalid time zone specification
      返回:
      a corresponding TimeZone instance
      抛出:
      IllegalArgumentException - in case of an invalid time zone specification
    • addStringToArray

      public static String[] addStringToArray(String[] array, String str)
      Append the given String to the given String array, returning a new array consisting of the input array contents plus the given String.
      参数:
      array - the array to append to (can be null)
      str - the String to append
      返回:
      the new array (never null)
    • concatenateStringArrays

      public static String[] concatenateStringArrays(String[] array1, String[] array2)
      Concatenate the given String arrays into one, with overlapping array elements included twice.

      The order of elements in the original arrays is preserved.

      参数:
      array1 - the first array (can be null)
      array2 - the second array (can be null)
      返回:
      the new array (null if both given arrays were null)
    • mergeStringArrays

      public static String[] mergeStringArrays(String[] array1, String[] array2)
      Merge the given String arrays into one, with overlapping array elements only included once.

      The order of elements in the original arrays is preserved (with the exception of overlapping elements, which are only included on their first occurrence).

      参数:
      array1 - the first array (can be null)
      array2 - the second array (can be null)
      返回:
      the new array (null if both given arrays were null)
    • sortStringArray

      public static String[] sortStringArray(String[] array)
      Turn given source String array into sorted array.
      参数:
      array - the source array
      返回:
      the sorted array (never null)
    • toStringArray

      public static String[] toStringArray(Collection<String> collection)
      Copy the given Collection into a String array.

      The Collection must contain String elements only.

      参数:
      collection - the Collection to copy
      返回:
      the String array
    • toStringArray

      public static String[] toStringArray(Enumeration<String> enumeration)
      Copy the given Enumeration into a String array. The Enumeration must contain String elements only.
      参数:
      enumeration - the Enumeration to copy
      返回:
      the String array
    • trimArrayElements

      public static String[] trimArrayElements(String[] array)
      Trim the elements of the given String array, calling String.trim() on each of them.
      参数:
      array - the original String array
      返回:
      the resulting array (of the same size) with trimmed elements
    • removeDuplicateStrings

      public static String[] removeDuplicateStrings(String[] array)
      Remove duplicate strings from the given array.

      As of 4.2, it preserves the original order, as it uses a LinkedHashSet.

      参数:
      array - the String array
      返回:
      an array without duplicates, in natural sort order
    • split

      public static String[] split(String toSplit, String delimiter)
      Split a String at the first occurrence of the delimiter. Does not include the delimiter in the result.
      参数:
      toSplit - the string to split
      delimiter - to split the string up with
      返回:
      a two element array with index 0 being before the delimiter, and index 1 being after the delimiter (neither element includes the delimiter); or null if the delimiter wasn't found in the given input String
    • splitArrayElementsIntoProperties

      public static Properties splitArrayElementsIntoProperties(String[] array, String delimiter)
      Take an array of strings and split each element based on the given delimiter. A Properties instance is then generated, with the left of the delimiter providing the key, and the right of the delimiter providing the value.

      Will trim both the key and value before adding them to the Properties instance.

      参数:
      array - the array to process
      delimiter - to split each element using (typically the equals symbol)
      返回:
      a Properties instance representing the array contents, or null if the array to process was null or empty
    • splitArrayElementsIntoProperties

      public static Properties splitArrayElementsIntoProperties(String[] array, String delimiter, String charsToDelete)
      Take an array of strings and split each element based on the given delimiter. A Properties instance is then generated, with the left of the delimiter providing the key, and the right of the delimiter providing the value.

      Will trim both the key and value before adding them to the Properties instance.

      参数:
      array - the array to process
      delimiter - to split each element using (typically the equals symbol)
      charsToDelete - one or more characters to remove from each element prior to attempting the split operation (typically the quotation mark symbol), or null if no removal should occur
      返回:
      a Properties instance representing the array contents, or null if the array to process was null or empty
    • tokenizeToStringArray

      public static String[] tokenizeToStringArray(String str, String delimiters)
      Tokenize the given String into a String array via a StringTokenizer.

      Trims tokens and omits empty tokens.

      The given delimiters string can consist of any number of delimiter characters. Each of those characters can be used to separate tokens. A delimiter is always a single character; for multi-character delimiters, consider using delimitedListToStringArray(java.lang.String, java.lang.String).

      参数:
      str - the String to tokenize
      delimiters - the delimiter characters, assembled as a String (each of the characters is individually considered as a delimiter)
      返回:
      an array of the tokens
      另请参阅:
    • tokenizeToStringArray

      public static String[] tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens)
      Tokenize the given String into a String array via a StringTokenizer.

      The given delimiters string can consist of any number of delimiter characters. Each of those characters can be used to separate tokens. A delimiter is always a single character; for multi-character delimiters, consider using delimitedListToStringArray(java.lang.String, java.lang.String).

      参数:
      str - the String to tokenize
      delimiters - the delimiter characters, assembled as a String (each of the characters is individually considered as a delimiter)
      trimTokens - trim the tokens via String.trim()
      ignoreEmptyTokens - omit empty tokens from the result array (only applies to tokens that are empty after trimming; StringTokenizer will not consider subsequent delimiters as token in the first place).
      返回:
      an array of the tokens
      另请参阅:
    • delimitedListToStringArray

      public static String[] delimitedListToStringArray(String str, String delimiter)
      Take a String that is a delimited list and convert it into a String array.

      A single delimiter may consist of more than one character, but it will still be considered as a single delimiter string, rather than as bunch of potential delimiter characters, in contrast to tokenizeToStringArray(java.lang.String, java.lang.String).

      参数:
      str - the input String
      delimiter - the delimiter between elements (this is a single delimiter, rather than a bunch individual delimiter characters)
      返回:
      an array of the tokens in the list
      另请参阅:
    • delimitedListToStringArray

      public static String[] delimitedListToStringArray(String str, String delimiter, String charsToDelete)
      Take a String that is a delimited list and convert it into a String array.

      A single delimiter may consist of more than one character, but it will still be considered as a single delimiter string, rather than as bunch of potential delimiter characters, in contrast to tokenizeToStringArray(java.lang.String, java.lang.String).

      参数:
      str - the input String
      delimiter - the delimiter between elements (this is a single delimiter, rather than a bunch individual delimiter characters)
      charsToDelete - a set of characters to delete; useful for deleting unwanted line breaks: e.g. "\r\n\f" will delete all new lines and line feeds in a String
      返回:
      an array of the tokens in the list
      另请参阅:
    • commaDelimitedListToStringArray

      public static String[] commaDelimitedListToStringArray(String str)
      Convert a comma delimited list (e.g., a row from a CSV file) into an array of strings.
      参数:
      str - the input String
      返回:
      an array of strings, or the empty array in case of empty input
    • commaDelimitedListToSet

      public static Set<String> commaDelimitedListToSet(String str)
      Convert a comma delimited list (e.g., a row from a CSV file) into a set.

      Note that this will suppress duplicates, and as of 4.2, the elements in the returned set will preserve the original order in a LinkedHashSet.

      参数:
      str - the input String
      返回:
      a set of String entries in the list
      另请参阅:
    • collectionToDelimitedString

      public static String collectionToDelimitedString(Collection<?> coll, String delim, String prefix, String suffix)
      Convert a Collection to a delimited String (e.g. CSV).

      Useful for toString() implementations.

      参数:
      coll - the Collection to convert
      delim - the delimiter to use (typically a ",")
      prefix - the String to start each element with
      suffix - the String to end each element with
      返回:
      the delimited String
    • collectionToDelimitedString

      public static String collectionToDelimitedString(Collection<?> coll, String delim)
      Convert a Collection into a delimited String (e.g. CSV).

      Useful for toString() implementations.

      参数:
      coll - the Collection to convert
      delim - the delimiter to use (typically a ",")
      返回:
      the delimited String
    • collectionToCommaDelimitedString

      public static String collectionToCommaDelimitedString(Collection<?> coll)
      Convert a Collection into a delimited String (e.g., CSV).

      Useful for toString() implementations.

      参数:
      coll - the Collection to convert
      返回:
      the delimited String
    • arrayToDelimitedString

      public static String arrayToDelimitedString(Object[] arr, String delim)
      Convert a String array into a delimited String (e.g. CSV).

      Useful for toString() implementations.

      参数:
      arr - the array to display
      delim - the delimiter to use (typically a ",")
      返回:
      the delimited String
    • arrayToCommaDelimitedString

      public static String arrayToCommaDelimitedString(Object[] arr)
      Convert a String array into a comma delimited String (i.e., CSV).

      Useful for toString() implementations.

      参数:
      arr - the array to display
      返回:
      the delimited String
    • hashCode

      public static int hashCode(String str)
      返回正数的hashCode值
      参数:
      str - String
      返回:
      int
    • getExceptionStackInfo

      public static String getExceptionStackInfo(Exception _ex)
    • count

      public static int count(CharSequence content, char charForSearch)
      统计指定内容中包含指定字符的数量
      参数:
      content - 内容
      charForSearch - 被统计的字符
      返回:
      包含数量
    • generateIdByStr

      public static long generateIdByStr(String... strs)
      通过字符串生成long型id
      参数:
      strs -
      返回: