public class StringUtils extends Object
CharSequence or String utils.| 构造器和说明 |
|---|
StringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
contains(CharSequence str,
CharSequence searchStr)
Whether the
searchStr is in the str. |
static String |
emptyToDefault(String str,
String defaultStr)
return the
str if str is not empty, otherwise return defaultStr. |
static String |
emptyToNull(String str)
return the
str if str is not empty, otherwise return null. |
static String |
format(String template,
Object... args)
Format string with placeholder {}.
|
static boolean |
isBlank(CharSequence cs)
Whether the given
CharSequence is blank. |
static boolean |
isEmpty(CharSequence cs)
Whether the given
CharSequence is empty. |
static boolean |
isNotBlank(CharSequence cs)
Whether the given
CharSequence is not blank. |
static boolean |
isNotEmpty(CharSequence cs)
Whether the given
CharSequence is not empty. |
static <T> String |
join(Collection<T> coll,
Function<T,CharSequence> mapper,
String separator)
Join the
coll with separator. |
static <T> String |
join(Function<T,CharSequence> mapper,
String separator,
T... array)
Join the
array with separator. |
static String |
md5DigestAsHex(String str)
Md5 digest as hex.
|
static Collection<String> |
split(String str,
String splitter)
Split string by given splitter.
|
static String |
upperFirst(String str)
Make the first character uppercase.
|
static String |
upperFirstAndAddPrefix(String str,
String prefix)
Make the first character uppercase and add prefix.
|
@SafeVarargs public static <T> String join(Function<T,CharSequence> mapper, String separator, T... array)
array with separator.mapper - mapperseparator - separatorarray - arraypublic static <T> String join(Collection<T> coll, Function<T,CharSequence> mapper, String separator)
coll with separator.coll - collectionmapper - mapperseparator - separatorpublic static boolean contains(CharSequence str, CharSequence searchStr)
Whether the searchStr is in the str.
eg:
"abc", "abc" will return true"abc", "b" will return true"abc", "d" will return falsenull, "a" will return false"a", null will return falsenull, null will return falsestr - the CharSequence to check, may be nullsearchStr - the CharSequence to find, may be nullpublic static String format(String template, Object... args)
Format string with placeholder {}.
eg: "a{}c", "b" will return "abc"
template - templateargs - argspublic static boolean isEmpty(CharSequence cs)
Whether the given CharSequence is empty.
eg: null, "" will return true, "a", " " will return false.
cs - char sequencepublic static boolean isNotEmpty(CharSequence cs)
Whether the given CharSequence is not empty.
eg: null, "" will return false, "a", " " will return true.
cs - char sequencepublic static String emptyToDefault(String str, String defaultStr)
return the str if str is not empty, otherwise return defaultStr.
str - strdefaultStr - default strpublic static String emptyToNull(String str)
return the str if str is not empty, otherwise return null.
str - strpublic static String upperFirstAndAddPrefix(String str, String prefix)
Make the first character uppercase and add prefix.
eg: "bc", "a" will return "aBc", null, "a" will return "anull".
str - strprefix - prefixpublic static String upperFirst(String str)
Make the first character uppercase.
eg: "abc" will return "Abc".
str - strpublic static boolean isBlank(CharSequence cs)
Whether the given CharSequence is blank.
eg: null, "", " " will return true, "a" will return false.
cs - char sequencepublic static boolean isNotBlank(CharSequence cs)
Whether the given CharSequence is not blank.
eg: null, "", " " will return false, "a" will return true.
cs - char sequencepublic static String md5DigestAsHex(String str)
str - strpublic static Collection<String> split(String str, String splitter)
str - strsplitter - splitterCopyright © 2024. All rights reserved.