类 StringUtils
java.lang.Object
spring.turbo.util.StringUtils
String 相关工具- 从以下版本开始:
- 1.0.0
- 作者:
- 应卓
- 另请参阅:
-
方法概要
修饰符和类型方法说明static voidblankSafeAdd(Collection<String> collection, String element) 非空白字符串加入集合static voidblankSafeAddAll(Collection<String> collection, String... elements) 非空白字符串加入集合static voidblankSafeAddAll(Collection<String> collection, Collection<String> elements) 非空白字符串加入集合static Stringcapitalize(String string) 首字母大写static String[]逗号分隔字符串转化成字符串数组static String[]commaDelimitedListToStringArray(String string, boolean trimAllElements) 逗号分隔字符串转化成字符串数组static int比较两个字符串static int比较两个字符串static intcompareIgnoreCase(String string1, String string2) 比较两个字符串 (大小写不敏感)static intcompareIgnoreCase(String string1, String string2, boolean nullIsLess) 比较两个字符串 (大小写不敏感)static booleancontainsAllChars(String string, String charsToCheck) 判断字符串是否包含所有的指定的字符static booleancontainsAnyChars(String string, String charsToCheck) 判断字符串是否包含任意一个指定的字符static booleancontainsNoneChars(String string, String charsToCheck) 判断字符串是否不包含任意一个指定的字符static booleancontainsWhitespace(String string) 判断字符串是否包含白字符static intcountMatches(String string, char ch) 字符出现个数计数static StringdeleteChars(String string, String charsToDelete) 删除字符串中的指定字符static StringdeleteWhitespace(String string) 删除白字符static voidemptySafeAdd(Collection<String> collection, String element) 非空字符串加入集合static voidemptySafeAddAll(Collection<String> collection, String... elements) 非空字符串加入集合static voidemptySafeAddAll(Collection<String> collection, Collection<String> elements) 非空字符串加入集合static boolean判断一个字符串是否有指定的后缀static booleanendsWithIgnoreCase(String string, String suffix) 判断一个字符串是否有指定的后缀 (大小写不敏感)static StringfirstNonBlank(String... values) 查找第一个非Blank字符串static StringfirstNonEmpty(String... strings) 查找第一个非Empty字符串static boolean判断字符串是否为空白串static boolean判断字符串是否为空串static booleanisNotBlank(String string) 判断字符串是否不为空白串static booleanisNotEmpty(String string) 判断字符串是否不为空串static int获取字符串的长度static voidnullSafeAdd(Collection<String> collection, String element) 非null字符串加入集合static voidnullSafeAddAll(Collection<String> collection, String... elements) 非null字符串加入集合static voidnullSafeAddAll(Collection<String> collection, Collection<String> elements) 非null字符串加入集合static StringnullSafeJoin(Iterable<?> elements, String separator) 多个元素拼接成一个字符串 (忽略null元素)static StringnullSafeJoin(Object[] elements, String separator) 多个元素拼接成一个字符串 (忽略null元素)static StringnullSafeJoin(String[] elements, String separator) 多个元素拼接成一个字符串 (忽略null元素)static StringnullSafeJoin(Iterator<?> elements, String separator) 多个元素拼接成一个字符串 (忽略null元素)static String重复字符串static String字符串逆向static booleanstartsWith(String string, String prefix) 判断一个字符串是否有指定的前缀static booleanstartsWithIgnoreCase(String string, String prefix) 判断一个字符串是否有指定的前缀 (大小写不敏感)toCharList(String string) 字符串转换为字符List字符串转换为字符SettoCharStream(String string) 字符串转换为字符Streamstatic Stringuncapitalize(String string) 取消首字母大写
-
方法详细资料
-
isEmpty
判断字符串是否为空串- 参数:
string- 字符串- 返回:
- 判断结果
-
isNotEmpty
判断字符串是否不为空串- 参数:
string- 字符串- 返回:
- 判断结果
-
isBlank
判断字符串是否为空白串- 参数:
string- 字符串- 返回:
- 判断结果
-
isNotBlank
判断字符串是否不为空白串- 参数:
string- 字符串- 返回:
- 判断结果
-
length
获取字符串的长度- 参数:
string- 字符串- 返回:
- 长度
-
containsWhitespace
判断字符串是否包含白字符- 参数:
string- 字符串- 返回:
- 判断结果
-
containsAnyChars
判断字符串是否包含任意一个指定的字符- 参数:
string- 字符串charsToCheck- 需要检查的字符集- 返回:
- 检测结果
-
containsAllChars
判断字符串是否包含所有的指定的字符- 参数:
string- 字符串charsToCheck- 需要检查的字符集- 返回:
- 检测结果
-
containsNoneChars
判断字符串是否不包含任意一个指定的字符- 参数:
string- 字符串charsToCheck- 需要检查的字符集- 返回:
- 检测结果
-
countMatches
字符出现个数计数- 参数:
string- 字符串ch- 要查找的字符- 返回:
- 结果
-
deleteWhitespace
删除白字符- 参数:
string- 字符串- 返回:
- 结果
-
deleteChars
删除字符串中的指定字符- 参数:
string- 字符串charsToDelete- 待删除的字符集合- 返回:
- 结果
-
toCharStream
字符串转换为字符Stream- 参数:
string- 字符串- 返回:
- 实例
-
toCharList
字符串转换为字符List- 参数:
string- 字符串- 返回:
- 实例
-
toCharSet
字符串转换为字符Set- 参数:
string- 字符串- 返回:
- 实例
-
reverse
字符串逆向- 参数:
string- 字符串- 返回:
- 结果
-
commaDelimitedListToStringArray
逗号分隔字符串转化成字符串数组- 参数:
string- 逗号分隔的字符串- 返回:
- 结果
-
commaDelimitedListToStringArray
public static String[] commaDelimitedListToStringArray(@Nullable String string, boolean trimAllElements) 逗号分隔字符串转化成字符串数组- 参数:
string- 逗号分隔的字符串trimAllElements- 是否trim所有的子字符串- 返回:
- 结果
-
capitalize
首字母大写- 参数:
string- 字符串- 返回:
- 结果
- 另请参阅:
-
uncapitalize
取消首字母大写- 参数:
string- 字符串- 返回:
- 结果
- 另请参阅:
-
nullSafeAdd
非null字符串加入集合- 参数:
collection- 集合element- 字符串
-
nullSafeAddAll
非null字符串加入集合- 参数:
collection- 集合elements- 字符串(多个)
-
nullSafeAddAll
public static void nullSafeAddAll(Collection<String> collection, @Nullable Collection<String> elements) 非null字符串加入集合- 参数:
collection- 集合elements- 字符串(多个)
-
emptySafeAdd
非空字符串加入集合- 参数:
collection- 集合element- 字符串
-
emptySafeAddAll
非空字符串加入集合- 参数:
collection- 集合elements- 字符串(多个)
-
emptySafeAddAll
public static void emptySafeAddAll(Collection<String> collection, @Nullable Collection<String> elements) 非空字符串加入集合- 参数:
collection- 集合elements- 字符串(多个)
-
blankSafeAdd
非空白字符串加入集合- 参数:
collection- 集合element- 字符串
-
blankSafeAddAll
非空白字符串加入集合- 参数:
collection- 集合elements- 字符串(多个)
-
blankSafeAddAll
public static void blankSafeAddAll(Collection<String> collection, @Nullable Collection<String> elements) 非空白字符串加入集合- 参数:
collection- 集合elements- 字符串(多个)
-
nullSafeJoin
多个元素拼接成一个字符串 (忽略null元素)- 参数:
elements- 多个元素separator- 分隔符- 返回:
- 结果
-
nullSafeJoin
多个元素拼接成一个字符串 (忽略null元素)- 参数:
elements- 多个元素separator- 分隔符- 返回:
- 结果
-
nullSafeJoin
多个元素拼接成一个字符串 (忽略null元素)- 参数:
elements- 多个元素separator- 分隔符- 返回:
- 结果
-
nullSafeJoin
多个元素拼接成一个字符串 (忽略null元素)- 参数:
elements- 多个元素separator- 分隔符- 返回:
- 结果
-
startsWith
判断一个字符串是否有指定的前缀- 参数:
string- 字符串prefix- 前缀- 返回:
- 结果
-
endsWith
判断一个字符串是否有指定的后缀- 参数:
string- 字符串suffix- 后缀- 返回:
- 结果
-
startsWithIgnoreCase
判断一个字符串是否有指定的前缀 (大小写不敏感)- 参数:
string- 字符串prefix- 前缀- 返回:
- 结果
-
endsWithIgnoreCase
判断一个字符串是否有指定的后缀 (大小写不敏感)- 参数:
string- 字符串suffix- 后缀- 返回:
- 结果
-
repeat
重复字符串- 参数:
string- 字符串n- 重复的次数- 返回:
- 结果
-
compare
比较两个字符串- 参数:
string1- 字符串1string2- 字符串2- 返回:
- 结果
-
compare
比较两个字符串- 参数:
string1- 字符串1string2- 字符串2nullIsLess- 为true时null排在前面- 返回:
- 结果
-
compareIgnoreCase
比较两个字符串 (大小写不敏感)- 参数:
string1- 字符串1string2- 字符串2- 返回:
- 结果
-
compareIgnoreCase
public static int compareIgnoreCase(@Nullable String string1, @Nullable String string2, boolean nullIsLess) 比较两个字符串 (大小写不敏感)- 参数:
string1- 字符串1string2- 字符串2nullIsLess- 为true时null排在前面- 返回:
- 结果
-
firstNonEmpty
查找第一个非Empty字符串- 参数:
strings- 字符串组- 返回:
- 结果或
null
-
firstNonBlank
查找第一个非Blank字符串- 参数:
values- 字符串组- 返回:
- 结果或
null
-