Package org.qiunet.utils.string
Class StringUtil
java.lang.Object
org.qiunet.utils.string.StringUtil
字符处理相关的工具类
- Author:
- qiunet
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> StringarraysToString(Collection<T> arrays, String start, String end, String separator) 数组拼串static <T> StringarraysToString(T[] arrays, String separator) 数组拼串static <T> StringarraysToString(T[] arrays, String start, String end, int startIndex, int endIndex, String separator) 数组拼串static <T> StringarraysToString(T[] arrays, String start, String end, String separator) 数组拼串static <T extends Number>
T[]conversion(String[] k, Class<T> t) 字符串数组 转 基础数据类型数组static <T extends Number>
T[]conversion(String src, String split, Class<T> t) 分隔字符串并转类型static booleanCompares two Strings, returningtrueif they are equal.static String格式化输出字符串 格式: format("xx{0}x{1}xx{0}x", "参数1", "参数2") 跟sformat比较, 这里的参数占位符可以重复使用.static StringgetByteHexVal(byte val) static StringgetIntHexVal(int val) static intgetMixedStringLength(String input) 计算中英文混合情况下的真实字数 汉字 占长度 2 字母 占长度 1static StringgetShortHexVal(short val) static boolean判断是否是空字符串static boolean是不是字符串static StringmapToString(Map<?, ?> map, String keyValSeparator, String separator) map 拼串static Stringmap 拼串static StringpowerfulTrim(String str) 屏蔽两端大部分空白字符static StringrandomString(int count) 生成一定长度的随机字符串static boolean返回是否符合正则表达式static boolean是否完美匹配static booleanregexChinese(String matchStr) 是否是汉字static intregexCount(String matchStr, String regex) 返回符合正则表达式的个数static String对string 重复 count次static Stringslf4jFormat(String string, Object... params) 格式化字符串 格式: sformat("xx{}xxx{}xx", "参数1", "参数2")static String[]分割字符串 跟string.split() 略有不同.
-
Field Details
-
CHINESE_REGEX
汉字的正则表达式 -
EMPTY_STRING
空字符串- See Also:
-
-
Method Details
-
isEmpty
判断是否是空字符串- Returns:
-
split
分割字符串 跟string.split() 略有不同. 不会按照正则表达式分割. 严格按照分隔符号分割字符串. 例: ",".split(",").length = 0 gameutil.split("," , ",").length = 2- Parameters:
srcStr-splitStr-- Returns:
-
conversion
字符串数组 转 基础数据类型数组- Type Parameters:
T-- Parameters:
k-t-- Returns:
-
conversion
分隔字符串并转类型- Parameters:
src-split-t-- Returns:
-
arraysToString
数组拼串- Parameters:
arrays-separator-- Returns:
-
arraysToString
数组拼串- Parameters:
arrays-separator-- Returns:
-
arraysToString
public static <T> String arraysToString(T[] arrays, String start, String end, int startIndex, int endIndex, String separator) 数组拼串- Parameters:
arrays-separator-- Returns:
-
arraysToString
public static <T> String arraysToString(Collection<T> arrays, String start, String end, String separator) 数组拼串- Parameters:
arrays-separator-- Returns:
-
mapToString
public static String mapToString(Map<?, ?> map, String keyValSeparator, String separator, String start, String end) map 拼串- Parameters:
keyValSeparator- key val 中间分隔符号separator- 两组key val 分割符号start- 初始位置字符end- 结束位置字符- Returns:
-
mapToString
map 拼串- Parameters:
keyValSeparator- key val 中间分隔符号separator- 两组key val 分割符号- Returns:
-
regex
返回是否符合正则表达式- Parameters:
matchStr-regex-- Returns:
-
isNum
是不是字符串- Parameters:
numStr-- Returns:
-
regex
是否完美匹配- Parameters:
matchStr-p-- Returns:
-
regexCount
返回符合正则表达式的个数- Parameters:
matchStr-regex-- Returns:
-
regexChinese
是否是汉字- Parameters:
matchStr-- Returns:
-
format
格式化输出字符串 格式: format("xx{0}x{1}xx{0}x", "参数1", "参数2") 跟sformat比较, 这里的参数占位符可以重复使用.- Parameters:
string-params-- Returns:
-
slf4jFormat
格式化字符串 格式: sformat("xx{}xxx{}xx", "参数1", "参数2")- Parameters:
string-params-- Returns:
-
getIntHexVal
-
getByteHexVal
-
getShortHexVal
-
randomString
生成一定长度的随机字符串- Parameters:
count-- Returns:
-
repeated
对string 重复 count次- Parameters:
string-count-- Returns:
-
powerfulTrim
屏蔽两端大部分空白字符- Returns:
-
getMixedStringLength
计算中英文混合情况下的真实字数 汉字 占长度 2 字母 占长度 1- Parameters:
input-- Returns:
-
equals
Compares two Strings, returning
trueif they are equal.nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case sensitive.StringUtils.equals(null, null) = true StringUtils.equals(null, "abc") = false StringUtils.equals("abc", null) = false StringUtils.equals("abc", "abc") = true StringUtils.equals("abc", "ABC") = false- Parameters:
str1- the first String, may be nullstr2- the second String, may be null- Returns:
trueif the Strings are equal, case sensitive, or bothnull- See Also:
-