类 StringUtil
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static String[]addStringToArray(String[] array, String str) Append the givenStringto the givenStringarray, returning a new array consisting of the input array contents plus the givenString.static StringapplyRelativePath(String path, String relativePath) Apply the given relative path to the given Java resource path, assuming standard Java folder separation (i.e. "/" separators).static StringConvert aStringarray into a comma delimitedString(i.e., CSV).static StringarrayToDelimitedString(Object[] arr, String delim) Convert aStringarray into a delimitedString(e.g.static StringarrayToString(String[] strs) static StringarrayToString(String[] strs, String separator, String firstLastPrefix) 数组转化为字符串static StringbyteToHexString(byte[] bytes) 将byte转化为16进制static StringbyteToHexString(byte[] bytes, int start, int end) 将byte数据转化为16进制字符串static Stringcapitalize(String str) Capitalize aString, changing the first letter to upper case as perCharacter.toUpperCase(char).static booleancheckSequence(String str) 判断输入是否有效static StringNormalize the path by suppressing sequences like "path/.." and inner simple dots.static StringConvert aCollectioninto a delimitedString(e.g., CSV).static StringcollectionToDelimitedString(Collection<?> coll, String delim) Convert aCollectioninto a delimitedString(e.g.static StringcollectionToDelimitedString(Collection<?> coll, String delim, String prefix, String suffix) Convert aCollectionto a delimitedString(e.g.Convert a comma delimited list (e.g., a row from a CSV file) into a set.static String[]Convert a comma delimited list (e.g., a row from a CSV file) into an array of strings.static String[]concatenateStringArrays(String[] array1, String[] array2) Concatenate the givenStringarrays into one, with overlapping array elements included twice.static booleanCheck whether the givenCharSequencecontains any whitespace characters.static booleancontainsWhitespace(String str) Check whether the givenStringcontains any whitespace characters.static Doubleconvert2Double(String str) 将字符串转化为Double对象static Integerconvert2Integer(String str) 将字符串转化为整形对象static Longconvert2Long(String str) static StringconvertNull2Default(String str, String defaultValue) static StringconvertNull2Empty(String str) 判断字符串是否为空static StringconvertUnicodeToString(String input) 将unicode字符串转为标准中文static intcount(CharSequence content, char charForSearch) 统计指定内容中包含指定字符的数量static intcountOccurrencesOf(String str, String sub) Count the occurrences of the substringsubin stringstr.static StringcutContent(String str, int len) 判断字符串是否超过指定长度的中文字符,超出则截取字符串返回,如果需要截取,则以...结尾static StringcutContent(String str, int len, String end) 判断字符串是否超过指定长度的中文字符,超出则截取字符串返回static String解密字符串static StringdecodeCharacter(String str) static StringdecorateStringLikeArray(String[] str, String left) static StringdecorateStringLikeArray(String[] array, String left, String right, String regex) static StringdecorateStringLikeArray(String str, String left) 修饰字符串static StringdecorateStringLikeArray(String str, String left, String right, String regex) 修饰字符串static StringDelete all occurrences of the given substring.static StringDelete any character in a givenString.static String[]delimitedListToStringArray(String str, String delimiter) Take aStringthat is a delimited list and convert it into aStringarray.static String[]delimitedListToStringArray(String str, String delimiter, String charsToDelete) Take aStringthat is a delimited list and convert it into aStringarray.static String加密字符串static StringencodeCharacter(String str) static booleanendsWithIgnoreCase(String str, String suffix) Test if the givenStringends with the specified suffix, ignoring upper/lower case.static boolean判断两个字符串是否相等,包括同时为nullstatic StringescapeHTML(String string) Escapes HTML Special characters present in the string.static String格式化字符串static longgenerateIdByStr(String... strs) 通过字符串生成long型idgetArgList(String... args) 将给定的参数组合成List对象static Stringstatic StringgetFilename(String path) Extract the filename from the given Java resource path, e.g.static StringgetFilenameExtension(String path) Extract the filename extension from the given Java resource path,static StringgetGUID()static Stringstatic String获取指定线程中的堆栈信息static int字符串中包含的中文字符数static int返回正数的hashCode值static booleanhasLength(CharSequence str) static booleanCheck that the givenStringis neithernullnor of length 0.static booleanhasText(CharSequence str) static booleanCheck whether the givenStringcontains actual text.static booleanhasUnicodeStr(String str) 查找字符串是否存在中文字符static byte[]hexStringToByte(String hex) 将16进制的字符串还原为byte数组static Stringstatic StringinputStream2String(InputStream is, String addEnter, String charset) 将字符中流转化为字符串static boolean是否空字符串static booleanisCharacter(String str) 判断是否全为字母static booleanisCharacterOrDigit(String str) 判断字符串是否为数字或字母static booleanisChinese(char c) 字符是否为汉字static boolean判断是否数字static booleanstatic booleanstatic booleanisMessyCode(String strName) 判断字符是否乱码static booleanisNotBlank(String str) 是否非空字符串static booleanisNotEmpty(String str) static boolean如果至少有一个汉字,则返回真static String如果str的长度小于size,则会在字符串的左边增加padStr字符串static String如果str的长度小于size,则会在字符串的左边增加padStr字符串static String[]mergeStringArrays(String[] array1, String[] array2) Merge the givenStringarrays into one, with overlapping array elements only included once.static StringnameBeautify(String str) 命名美化,仅支持将_去掉并将下一个单词转化为首字母大写static LocaleparseLocaleString(String localeString) Parse the givenlocaleStringvalue into aLocale.static TimeZoneparseTimeZoneString(String timeZoneString) Parse the giventimeZoneStringvalue into aTimeZone.static booleanpathEquals(String path1, String path2) Compare two paths after normalization of them.static StringQuote the givenStringwith single quotes.static ObjectquoteIfString(Object obj) Turn the given Object into aStringwith single quotes if it is aString; keeping the Object as-is else.static String[]removeDuplicateStrings(String[] array) Remove duplicate strings from the given array.static StringReplace all occurrences of a substring within a string with another string.static StringreplaceString(String source, String tag, String value) 将指定字符串中的标记用相应的字符串替换掉static String如果str的长度小于size,则会在字符串的右边增加padStr字符串static String如果str的长度小于size,则会在字符串的右边增加padStr字符串static int获取字符串占用字节数static String[]sortStringArray(String[] array) Turn given sourceStringarray into sorted array.取代String.split (正则表达式) 效率提高1倍,同时避免 | 等字符引起的分隔问题static String[]Split aStringat the first occurrence of the delimiter.static PropertiessplitArrayElementsIntoProperties(String[] array, String delimiter) Take an array of strings and split each element based on the given delimiter.static PropertiessplitArrayElementsIntoProperties(String[] array, String delimiter, String charsToDelete) Take an array of strings and split each element based on the given delimiter.static booleanstartsWithIgnoreCase(String str, String prefix) Test if the givenStringstarts with the specified prefix, ignoring upper/lower case.static InputStreamString2InputStream(String str) 将字符串转化为InputStream流对象static String将堆栈里的数据转化为字符串static StringstripFilenameExtension(String path) Strip the filename extension from the given Java resource path,static booleansubstringMatch(CharSequence str, int index, CharSequence substring) Test whether the given string matches the given substring at the given index.static StringtimeFormat(int sec) 格式化时间static StringtimeFormat(long time) 格式化时间static StringtimeFormat(Double sec) 格式化时间static StringtimeFormat(String sec) 格式化时间static StringtimeFormatFull(long time) static String[]tokenizeToStringArray(String str, String delimiters) static String[]tokenizeToStringArray(String str, String delimiters, boolean trimTokens, boolean ignoreEmptyTokens) static StringtoLanguageTag(Locale locale) Determine the RFC 3066 compliant language tag, as used for the HTTP "Accept-Language" header.static String[]toStringArray(Collection<String> collection) Copy the givenCollectioninto aStringarray.static String[]toStringArray(Enumeration<String> enumeration) Copy the given Enumeration into aStringarray.static String清除所有空格static StringtrimAllWhitespace(String str) Trim all whitespace from the givenString: leading, trailing, and in between characters.static String[]trimArrayElements(String[] array) Trim the elements of the givenStringarray, callingString.trim()on each of them.static StringtrimLeadingCharacter(String str, char leadingCharacter) Trim all occurrences of the supplied leading character from the givenString.static StringTrim leading whitespace from the givenString.static StringtrimTrailingCharacter(String str, char trailingCharacter) Trim all occurrences of the supplied trailing character from the givenString.static StringTrim trailing whitespace from the givenString.static StringtrimWhitespace(String str) Trim leading and trailing whitespace from the givenString.static Stringuncapitalize(String str) Uncapitalize aString, changing the first letter to lower case as perCharacter.toLowerCase(char).static intunicodeCount(String str) 获取字符串中包括的字符数static StringUnqualify a string qualified by a '.' dot character.static StringUnqualify a string qualified by a separator character.
-
构造器详细资料
-
StringUtil
public StringUtil()
-
-
方法详细资料
-
isStringHasWideChar
如果至少有一个汉字,则返回真- 参数:
s- 字符串- 返回:
- true|false
-
getWideCharCount
字符串中包含的中文字符数- 参数:
s- 字符串- 返回:
- int
-
sizeof
获取字符串占用字节数- 参数:
str- String- 返回:
- int
-
getArgList
将给定的参数组合成List对象- 参数:
args- 可变参数- 返回:
- List
-
isNotBlank
是否非空字符串- 参数:
str- String- 返回:
- boolean
-
isBlank
是否空字符串- 参数:
str- String- 返回:
- boolean
-
String2InputStream
将字符串转化为InputStream流对象- 参数:
str- String- 返回:
- InputStream
-
inputStream2String
-
inputStream2String
将字符中流转化为字符串- 参数:
is- InputStreamaddEnter- 行后面添加换行标识charset- String- 返回:
- String
-
split
取代String.split (正则表达式) 效率提高1倍,同时避免 | 等字符引起的分隔问题- 参数:
text- Stringseparator- char- 返回:
- List
-
convert2Double
将字符串转化为Double对象- 参数:
str- String- 返回:
- Double
-
convert2Integer
将字符串转化为整形对象- 参数:
str- String- 返回:
- Integer
-
convert2Long
-
convertNull2Empty
判断字符串是否为空- 参数:
str- String- 返回:
- String
-
convertNull2Default
-
hasUnicodeStr
查找字符串是否存在中文字符- 参数:
str- String- 返回:
- boolean
-
unicodeCount
获取字符串中包括的字符数- 参数:
str- String- 返回:
- int
-
convertUnicodeToString
将unicode字符串转为标准中文- 参数:
input-- 返回:
-
checkSequence
判断输入是否有效- 参数:
str- String- 返回:
- boolean
-
isDigit
判断是否数字- 参数:
str- String- 返回:
- boolean
-
isCharacter
判断是否全为字母- 参数:
str- String- 返回:
- boolean
-
lpad
如果str的长度小于size,则会在字符串的左边增加padStr字符串- 参数:
str- 源字符串size- 最小长度padStr- 填充字符串- 返回:
- String
-
lpad
如果str的长度小于size,则会在字符串的左边增加padStr字符串- 参数:
str- 源字符串size- 最小长度padStr- 填充字符- 返回:
- String
-
rpad
如果str的长度小于size,则会在字符串的右边增加padStr字符串- 参数:
str- 源字符串size- 最小长度padStr- 填充字符串- 返回:
- String
-
rpad
如果str的长度小于size,则会在字符串的右边增加padStr字符串- 参数:
str- 源字符串size- 最小长度padStr- 填充字符- 返回:
- String
-
trimAll
清除所有空格- 参数:
str- String- 返回:
- String
-
timeFormat
格式化时间- 参数:
sec- 时间字符串(单位:秒)- 返回:
- 00:00:00
-
timeFormat
格式化时间- 参数:
sec- 时间(单位:秒)- 返回:
- 00:00:00
-
timeFormat
格式化时间- 参数:
sec- 时间(单位:秒)- 返回:
- 00:00:00
-
timeFormat
格式化时间- 参数:
time- 时间(单位:秒)- 返回:
- 00:00:00
-
timeFormatFull
-
format
格式化字符串- 参数:
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
将指定字符串中的标记用相应的字符串替换掉- 参数:
source- 需要替换的字符串tag- 标记value- 替换值- 返回:
- 相关标记被替换的字符串
-
isMessyCode
判断字符是否乱码- 参数:
strName- 待检查字符串- 返回:
- boolean
-
isChinese
public static boolean isChinese(char c) 字符是否为汉字- 参数:
c- char- 返回:
- boolean
-
isCharacterOrDigit
判断字符串是否为数字或字母- 参数:
str-- 返回:
-
encodeAES
加密字符串- 参数:
str- String- 返回:
- String
- 抛出:
Exception- Exception
-
decodeAES
解密字符串- 参数:
estr- String- 返回:
- String
- 抛出:
Exception- Exception
-
encodeCharacter
-
decodeCharacter
-
decorateStringLikeArray
修饰字符串- 参数:
str- 待修饰字符串,如:01,02,03left- 左边填充值right- 右边填充值,为空是同左边regex- 间隔值,为空时默认英文逗号- 返回:
- 修饰后的值,如:'01','02','03'
-
decorateStringLikeArray
-
decorateStringLikeArray
修饰字符串- 参数:
str- 待修饰字符串,如:01,02,03left- 左边填充值- 返回:
- 修饰后的值,如:'01','02','03'
-
decorateStringLikeArray
-
stringifyException
将堆栈里的数据转化为字符串- 参数:
e- 堆栈- 返回:
- String
-
arrayToString
数组转化为字符串- 参数:
strs- 数组separator- 中间分隔符 默认逗号firstLastPrefix- 每项中前后值 默认为单引号- 返回:
- arrayToString(new String[]{"a","b","c"},",","'") 如:[a,b,c] 转化为 'a','b','c'
-
arrayToString
-
byteToHexString
将byte数据转化为16进制字符串- 参数:
bytes- 数组start- 开始位置end- 结束位置- 返回:
- String
-
byteToHexString
将byte转化为16进制- 参数:
bytes- byte[]- 返回:
- String
-
hexStringToByte
将16进制的字符串还原为byte数组- 参数:
hex- 16进制字符串- 返回:
- byte[]
-
nameBeautify
命名美化,仅支持将_去掉并将下一个单词转化为首字母大写- 参数:
str- user_id- 返回:
- userId
-
equals
判断两个字符串是否相等,包括同时为null- 参数:
str1-str2-- 返回:
-
escapeHTML
Escapes HTML Special characters present in the string.- 参数:
string- String- 返回:
- HTML Escaped String representation
-
getStackTrace
获取指定线程中的堆栈信息- 参数:
t- Thread- 返回:
- String
-
getLineSeparator
-
cutContent
判断字符串是否超过指定长度的中文字符,超出则截取字符串返回,如果需要截取,则以...结尾- 参数:
str- 待判断的字符串len- 中文字符个数- 返回:
- String
-
cutContent
判断字符串是否超过指定长度的中文字符,超出则截取字符串返回- 参数:
str- 待判断的字符串len- 中文字符个数end- 结尾符,默认:...- 返回:
- String
-
getGUID
-
isEmpty
-
isEmpty
-
isNotEmpty
-
hasLength
-
hasLength
Check that the givenStringis neithernullnor of length 0.Note: this method returns
truefor aStringthat purely consists of whitespace.- 参数:
str- theStringto check (may benull)- 返回:
trueif theStringis notnulland has length- 另请参阅:
-
hasText
-
hasText
Check whether the givenStringcontains actual text.More specifically, this method returns
trueif theStringis notnull, its length is greater than 0, and it contains at least one non-whitespace character.- 参数:
str- theStringto check (may benull)- 返回:
trueif theStringis notnull, its length is greater than 0, and it does not contain whitespace only- 另请参阅:
-
containsWhitespace
Check whether the givenCharSequencecontains any whitespace characters.- 参数:
str- theCharSequenceto check (may benull)- 返回:
trueif theCharSequenceis not empty and contains at least 1 whitespace character- 另请参阅:
-
containsWhitespace
Check whether the givenStringcontains any whitespace characters.- 参数:
str- theStringto check (may benull)- 返回:
trueif theStringis not empty and contains at least 1 whitespace character- 另请参阅:
-
trimWhitespace
Trim leading and trailing whitespace from the givenString.- 参数:
str- theStringto check- 返回:
- the trimmed
String - 另请参阅:
-
trimAllWhitespace
Trim all whitespace from the givenString: leading, trailing, and in between characters.- 参数:
str- theStringto check- 返回:
- the trimmed
String - 另请参阅:
-
trimLeadingWhitespace
Trim leading whitespace from the givenString.- 参数:
str- theStringto check- 返回:
- the trimmed
String - 另请参阅:
-
trimTrailingWhitespace
Trim trailing whitespace from the givenString.- 参数:
str- theStringto check- 返回:
- the trimmed
String - 另请参阅:
-
trimLeadingCharacter
Trim all occurrences of the supplied leading character from the givenString.- 参数:
str- theStringto checkleadingCharacter- the leading character to be trimmed- 返回:
- the trimmed
String
-
trimTrailingCharacter
Trim all occurrences of the supplied trailing character from the givenString.- 参数:
str- theStringto checktrailingCharacter- the trailing character to be trimmed- 返回:
- the trimmed
String
-
startsWithIgnoreCase
Test if the givenStringstarts with the specified prefix, ignoring upper/lower case.- 参数:
str- theStringto checkprefix- the prefix to look for- 返回:
- boolean
- 另请参阅:
-
endsWithIgnoreCase
Test if the givenStringends with the specified suffix, ignoring upper/lower case.- 参数:
str- theStringto checksuffix- the suffix to look for- 返回:
- boolean
- 另请参阅:
-
substringMatch
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 againstsubstring- the substring to match at the given index- 返回:
- boolean
-
countOccurrencesOf
Count the occurrences of the substringsubin stringstr.- 参数:
str- string to search insub- string to search for- 返回:
- int
-
replace
Replace all occurrences of a substring within a string with another string.- 参数:
inString-Stringto examineoldPattern-Stringto replacenewPattern-Stringto insert- 返回:
- a
Stringwith the replacements
-
delete
Delete all occurrences of the given substring.- 参数:
inString- the originalStringpattern- the pattern to delete all occurrences of- 返回:
- the resulting
String
-
deleteAny
Delete any character in a givenString.- 参数:
inString- the originalStringcharsToDelete- a set of characters to delete. E.g. "az\n" will delete 'a's, 'z's and new lines.- 返回:
- the resulting
String
-
quote
Quote the givenStringwith single quotes.- 参数:
str- the inputString(e.g. "myString")- 返回:
- the quoted
String(e.g. "'myString'"), ornullif the input wasnull
-
quoteIfString
Turn the given Object into aStringwith single quotes if it is aString; 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 aString
-
unqualify
Unqualify a string qualified by a '.' dot character. For example, "this.name.is.qualified", returns "qualified".- 参数:
qualifiedName- the qualified name- 返回:
- String
-
unqualify
Unqualify a string qualified by a separator character. For example, "this:name:is:qualified" returns "qualified" if using a ':' separator.- 参数:
qualifiedName- the qualified nameseparator- the separator- 返回:
- String
-
capitalize
Capitalize aString, changing the first letter to upper case as perCharacter.toUpperCase(char). No other letters are changed.- 参数:
str- theStringto capitalize- 返回:
- the capitalized
String
-
uncapitalize
Uncapitalize aString, changing the first letter to lower case as perCharacter.toLowerCase(char). No other letters are changed.- 参数:
str- theStringto uncapitalize- 返回:
- the uncapitalized
String
-
getFilename
Extract the filename from the given Java resource path, e.g."mypath/myfile.txt" -> "myfile.txt".- 参数:
path- the file path (may benull)- 返回:
- the extracted filename, or
nullif none
-
getFilenameExtension
Extract the filename extension from the given Java resource path,- 参数:
path- the file path (may benull)- 返回:
- the extracted filename extension, or
nullif none
-
stripFilenameExtension
Strip the filename extension from the given Java resource path,- 参数:
path- the file path- 返回:
- the path with stripped filename extension
-
applyRelativePath
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
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
Compare two paths after normalization of them.- 参数:
path1- first path for comparisonpath2- second path for comparison- 返回:
- whether the two paths are equivalent after normalization
-
parseLocaleString
Parse the givenlocaleStringvalue into aLocale.This is the inverse operation of
Locale's toString.- 参数:
localeString- the localeString, followingLocale'stoString()format ("en", "en_UK", etc); also accepts spaces as separators, as an alternative to underscores- 返回:
- a corresponding
Localeinstance, ornullif none - 抛出:
IllegalArgumentException- in case of an invalid locale specification
-
toLanguageTag
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
Parse the giventimeZoneStringvalue into aTimeZone.- 参数:
timeZoneString- the time zoneString, followingTimeZone.getTimeZone(String)but throwingIllegalArgumentExceptionin case of an invalid time zone specification- 返回:
- a corresponding
TimeZoneinstance - 抛出:
IllegalArgumentException- in case of an invalid time zone specification
-
addStringToArray
Append the givenStringto the givenStringarray, returning a new array consisting of the input array contents plus the givenString.- 参数:
array- the array to append to (can benull)str- theStringto append- 返回:
- the new array (never
null)
-
concatenateStringArrays
Concatenate the givenStringarrays into one, with overlapping array elements included twice.The order of elements in the original arrays is preserved.
- 参数:
array1- the first array (can benull)array2- the second array (can benull)- 返回:
- the new array (
nullif both given arrays werenull)
-
mergeStringArrays
Merge the givenStringarrays 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 benull)array2- the second array (can benull)- 返回:
- the new array (
nullif both given arrays werenull)
-
sortStringArray
Turn given sourceStringarray into sorted array.- 参数:
array- the source array- 返回:
- the sorted array (never
null)
-
toStringArray
Copy the givenCollectioninto aStringarray.The
Collectionmust containStringelements only.- 参数:
collection- theCollectionto copy- 返回:
- the
Stringarray
-
toStringArray
Copy the given Enumeration into aStringarray. The Enumeration must containStringelements only.- 参数:
enumeration- the Enumeration to copy- 返回:
- the
Stringarray
-
trimArrayElements
Trim the elements of the givenStringarray, callingString.trim()on each of them.- 参数:
array- the originalStringarray- 返回:
- the resulting array (of the same size) with trimmed elements
-
removeDuplicateStrings
Remove duplicate strings from the given array.As of 4.2, it preserves the original order, as it uses a
LinkedHashSet.- 参数:
array- theStringarray- 返回:
- an array without duplicates, in natural sort order
-
split
Split aStringat the first occurrence of the delimiter. Does not include the delimiter in the result.- 参数:
toSplit- the string to splitdelimiter- 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
nullif the delimiter wasn't found in the given inputString
-
splitArrayElementsIntoProperties
Take an array of strings and split each element based on the given delimiter. APropertiesinstance 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
Propertiesinstance.- 参数:
array- the array to processdelimiter- to split each element using (typically the equals symbol)- 返回:
- a
Propertiesinstance representing the array contents, ornullif the array to process wasnullor 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. APropertiesinstance 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
Propertiesinstance.- 参数:
array- the array to processdelimiter- 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), ornullif no removal should occur- 返回:
- a
Propertiesinstance representing the array contents, ornullif the array to process wasnullor empty
-
tokenizeToStringArray
Tokenize the givenStringinto aStringarray via aStringTokenizer.Trims tokens and omits empty tokens.
The given
delimitersstring 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 usingdelimitedListToStringArray(java.lang.String, java.lang.String).- 参数:
str- theStringto tokenizedelimiters- the delimiter characters, assembled as aString(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 givenStringinto aStringarray via aStringTokenizer.The given
delimitersstring 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 usingdelimitedListToStringArray(java.lang.String, java.lang.String).- 参数:
str- theStringto tokenizedelimiters- the delimiter characters, assembled as aString(each of the characters is individually considered as a delimiter)trimTokens- trim the tokens viaString.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
Take aStringthat is a delimited list and convert it into aStringarray.A single
delimitermay 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 totokenizeToStringArray(java.lang.String, java.lang.String).- 参数:
str- the inputStringdelimiter- 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 aStringthat is a delimited list and convert it into aStringarray.A single
delimitermay 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 totokenizeToStringArray(java.lang.String, java.lang.String).- 参数:
str- the inputStringdelimiter- 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 aString- 返回:
- an array of the tokens in the list
- 另请参阅:
-
commaDelimitedListToStringArray
Convert a comma delimited list (e.g., a row from a CSV file) into an array of strings.- 参数:
str- the inputString- 返回:
- an array of strings, or the empty array in case of empty input
-
commaDelimitedListToSet
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 inputString- 返回:
- a set of
Stringentries in the list - 另请参阅:
-
collectionToDelimitedString
public static String collectionToDelimitedString(Collection<?> coll, String delim, String prefix, String suffix) - 参数:
coll- theCollectionto convertdelim- the delimiter to use (typically a ",")prefix- theStringto start each element withsuffix- theStringto end each element with- 返回:
- the delimited
String
-
collectionToDelimitedString
Convert aCollectioninto a delimitedString(e.g. CSV).Useful for
toString()implementations.- 参数:
coll- theCollectionto convertdelim- the delimiter to use (typically a ",")- 返回:
- the delimited
String
-
collectionToCommaDelimitedString
Convert aCollectioninto a delimitedString(e.g., CSV).Useful for
toString()implementations.- 参数:
coll- theCollectionto convert- 返回:
- the delimited
String
-
arrayToDelimitedString
Convert aStringarray into a delimitedString(e.g. CSV).Useful for
toString()implementations.- 参数:
arr- the array to displaydelim- the delimiter to use (typically a ",")- 返回:
- the delimited
String
-
arrayToCommaDelimitedString
Convert aStringarray into a comma delimitedString(i.e., CSV).Useful for
toString()implementations.- 参数:
arr- the array to display- 返回:
- the delimited
String
-
hashCode
返回正数的hashCode值- 参数:
str- String- 返回:
- int
-
getExceptionStackInfo
-
count
统计指定内容中包含指定字符的数量- 参数:
content- 内容charForSearch- 被统计的字符- 返回:
- 包含数量
-
generateIdByStr
通过字符串生成long型id- 参数:
strs-- 返回:
-