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 String |
upperFirst(String str)
Make the first character uppercase.
|
static String |
upperFirstAndAddPrefix(String str,
String prefix)
Make the first character uppercase and add prefix.
|
public 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 sequenceCopyright © 2023. All rights reserved.