public class StringUtils
extends org.apache.commons.lang3.StringUtils
| 构造器和说明 |
|---|
StringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static <T> T |
cast(Object obj) |
static String |
convertToCamelCase(String name)
将下划线大写方式命名的字符串转换为驼峰式。
|
static String |
format(String template,
Object... params)
格式化文本, {} 表示占位符
此方法只是简单将占位符 {} 按照顺序替换为参数 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可 例: 通常使用:format("this is {} for {}", "a", "b") -> this is a for b 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b |
static boolean |
hasText(String str)
判断是否为空,并且不是空白字符
|
static boolean |
inStringIgnoreCase(String str,
String... strs)
是否包含字符串
|
static boolean |
isArray(Object object)
* 判断一个对象是否是数组类型(Java基本型别的数组)
|
static boolean |
isEmpty(Collection<?> coll)
* 判断一个Collection是否为空, 包含List,Set,Queue
|
static boolean |
isEmpty(Map<?,?> map)
* 判断一个Map是否为空
|
static boolean |
isEmpty(Object[] objects)
* 判断一个对象数组是否为空
|
static boolean |
isEmpty(String str)
* 判断一个字符串是否为空串
|
static boolean |
ishttp(String link)
是否为http(s)://开头
|
static boolean |
isMatch(String pattern,
String url)
判断url是否与规则配置:
?
|
static boolean |
isNotEmpty(Collection<?> coll)
* 判断一个Collection是否非空,包含List,Set,Queue
|
static boolean |
isNotEmpty(Map<?,?> map)
* 判断一个Map是否为空
|
static boolean |
isNotEmpty(Object[] objects)
* 判断一个对象数组是否非空
|
static boolean |
isNotEmpty(String str)
* 判断一个字符串是否为非空串
|
static boolean |
isNotNull(Object object)
* 判断一个对象是否非空
|
static boolean |
isNull(Object object)
* 判断一个对象是否为空
|
static boolean |
matches(String str,
List<String> strs)
查找指定字符串是否匹配指定字符串列表中的任意一个字符串
|
static <T> T |
nvl(T value,
T defaultValue)
获取参数不为空值
|
static String |
substring(String str,
int start)
截取字符串
|
static String |
substring(String str,
int start,
int end)
截取字符串
|
static String |
toCamelCase(String s)
驼峰式命名法 例如:user_name->userName
|
static String |
toUnderScoreCase(String str)
驼峰转下划线命名
|
static String |
trim(String str)
去空格
|
abbreviate, abbreviate, abbreviate, abbreviate, abbreviateMiddle, appendIfMissing, appendIfMissingIgnoreCase, capitalize, center, center, center, chomp, chomp, chop, compare, compare, compareIgnoreCase, compareIgnoreCase, contains, contains, containsAny, containsAny, containsAny, containsAnyIgnoreCase, containsIgnoreCase, containsNone, containsNone, containsOnly, containsOnly, containsWhitespace, countMatches, countMatches, defaultIfBlank, defaultIfEmpty, defaultString, defaultString, deleteWhitespace, difference, endsWith, endsWithAny, endsWithIgnoreCase, equals, equalsAny, equalsAnyIgnoreCase, equalsIgnoreCase, firstNonBlank, firstNonEmpty, getBytes, getBytes, getCommonPrefix, getDigits, getFuzzyDistance, getIfBlank, getIfEmpty, getJaroWinklerDistance, getLevenshteinDistance, getLevenshteinDistance, indexOf, indexOf, indexOf, indexOf, indexOfAny, indexOfAny, indexOfAny, indexOfAnyBut, indexOfAnyBut, indexOfDifference, indexOfDifference, indexOfIgnoreCase, indexOfIgnoreCase, isAllBlank, isAllEmpty, isAllLowerCase, isAllUpperCase, isAlpha, isAlphanumeric, isAlphanumericSpace, isAlphaSpace, isAnyBlank, isAnyEmpty, isAsciiPrintable, isBlank, isEmpty, isMixedCase, isNoneBlank, isNoneEmpty, isNotBlank, isNotEmpty, isNumeric, isNumericSpace, isWhitespace, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, join, joinWith, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOf, lastIndexOfAny, lastIndexOfIgnoreCase, lastIndexOfIgnoreCase, lastOrdinalIndexOf, left, leftPad, leftPad, leftPad, length, lowerCase, lowerCase, mid, normalizeSpace, ordinalIndexOf, overlay, prependIfMissing, prependIfMissingIgnoreCase, remove, remove, removeAll, removeEnd, removeEndIgnoreCase, removeFirst, removeIgnoreCase, removePattern, removeStart, removeStartIgnoreCase, repeat, repeat, repeat, replace, replace, replaceAll, replaceChars, replaceChars, replaceEach, replaceEachRepeatedly, replaceFirst, replaceIgnoreCase, replaceIgnoreCase, replaceOnce, replaceOnceIgnoreCase, replacePattern, reverse, reverseDelimited, right, rightPad, rightPad, rightPad, rotate, split, split, split, split, splitByCharacterType, splitByCharacterTypeCamelCase, splitByWholeSeparator, splitByWholeSeparator, splitByWholeSeparatorPreserveAllTokens, splitByWholeSeparatorPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, splitPreserveAllTokens, startsWith, startsWithAny, startsWithIgnoreCase, strip, strip, stripAccents, stripAll, stripAll, stripEnd, stripStart, stripToEmpty, stripToNull, substringAfter, substringAfter, substringAfterLast, substringAfterLast, substringBefore, substringBefore, substringBeforeLast, substringBetween, substringBetween, substringsBetween, swapCase, toCodePoints, toEncodedString, toRootLowerCase, toRootUpperCase, toString, trimToEmpty, trimToNull, truncate, truncate, uncapitalize, unwrap, unwrap, upperCase, upperCase, valueOf, wrap, wrap, wrapIfMissing, wrapIfMissingpublic static <T> T nvl(T value,
T defaultValue)
value - defaultValue 要判断的valuepublic static boolean isEmpty(Collection<?> coll)
coll - 要判断的Collectionpublic static boolean isNotEmpty(Collection<?> coll)
coll - 要判断的Collectionpublic static boolean isEmpty(Object[] objects)
objects - 要判断的对象数组public static boolean isNotEmpty(Object[] objects)
objects - 要判断的对象数组public static boolean isEmpty(Map<?,?> map)
map - 要判断的Mappublic static boolean isNotEmpty(Map<?,?> map)
map - 要判断的Mappublic static boolean isEmpty(String str)
str - Stringpublic static boolean isNotEmpty(String str)
str - Stringpublic static boolean isNull(Object object)
object - Objectpublic static boolean isNotNull(Object object)
object - Objectpublic static boolean isArray(Object object)
object - 对象public static String substring(String str, int start)
str - 字符串start - 开始public static String substring(String str, int start, int end)
str - 字符串start - 开始end - 结束public static boolean hasText(String str)
str - 要判断的valuepublic static String format(String template, Object... params)
template - 文本模板,被替换的部分用 {} 表示params - 参数值public static boolean ishttp(String link)
link - 链接public static boolean inStringIgnoreCase(String str, String... strs)
str - 验证字符串strs - 字符串组public static String convertToCamelCase(String name)
name - 转换前的下划线大写方式命名的字符串public static boolean matches(String str, List<String> strs)
str - 指定字符串strs - 需要检查的字符串数组public static boolean isMatch(String pattern, String url)
pattern - 匹配规则url - 需要匹配的urlpublic static <T> T cast(Object obj)
Copyright © 2021. All rights reserved.