public class StringUtils extends Object
| 构造器和说明 |
|---|
StringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
containsIgnoreCase(CharSequence str,
CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling
null. |
static String |
defaultIfEmpty(String str,
String defaultStr) |
static boolean |
equals(String str1,
String str2) |
static boolean |
equalsIgnoreCase(CharSequence str1,
CharSequence str2)
Compares two CharSequences, returning
true if they represent
equal sequences of characters, ignoring case. |
static String |
escapeJavaScript(String str) |
static boolean |
isAllBlank(String... strs)
Judge whether all strings are blank.
|
static boolean |
isBlank(String str)
Judge whether string is blank.
|
static boolean |
isEmpty(String str) |
static boolean |
isNotBlank(String str) |
static boolean |
isNotEmpty(String str) |
static String |
join(Collection collection,
String separator)
Join object with input separator.
|
static String |
newStringForUtf8(byte[] bytes) |
static String |
substringBetween(String str,
String open,
String close)
Substring between two index.
|
static String |
trim(String str) |
public static String newStringForUtf8(byte[] bytes)
public static boolean isBlank(String str)
str - stringpublic static boolean isAllBlank(String... strs)
strs - stringspublic static boolean isNotBlank(String str)
public static boolean isNotEmpty(String str)
public static boolean isEmpty(String str)
public static String substringBetween(String str, String open, String close)
str - stringopen - start index to subclose - end index to subpublic static String join(Collection collection, String separator)
collection - collection of objects need to joinseparator - separatorpublic static boolean containsIgnoreCase(CharSequence str, CharSequence searchStr)
null.
Case-insensitivity is defined as by String.equalsIgnoreCase(String).
A null CharSequence will return false.
StringUtils.contains(null, *) = false
StringUtils.contains(*, null) = false
StringUtils.contains("", "") = true
StringUtils.contains("abc", "") = true
StringUtils.contains("abc", "a") = true
StringUtils.contains("abc", "z") = false
StringUtils.contains("abc", "A") = true
StringUtils.contains("abc", "Z") = false
str - the CharSequence to check, may be nullsearchStr - the CharSequence to find, may be nullnull string inputpublic static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2)
Compares two CharSequences, returning true if they represent
equal sequences of characters, ignoring case.
nulls are handled without exceptions. Two null
references are considered equal. Comparison is case insensitive.
StringUtils.equalsIgnoreCase(null, null) = true
StringUtils.equalsIgnoreCase(null, "abc") = false
StringUtils.equalsIgnoreCase("abc", null) = false
StringUtils.equalsIgnoreCase("abc", "abc") = true
StringUtils.equalsIgnoreCase("abc", "ABC") = true
str1 - the first CharSequence, may be nullstr2 - the second CharSequence, may be nulltrue if the CharSequence are equal, case insensitive, or both nullCopyright © 2018–2020 Alibaba Group. All rights reserved.