| 构造器和说明 |
|---|
StringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
equals(CharSequence cs1,
CharSequence cs2)
Compares two CharSequences, returning
true if they represent
equal sequences of characters. |
static boolean |
isBlank(CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
|
static boolean |
isEmpty(CharSequence cs)
Checks if a CharSequence is empty ("") or null.
|
static boolean |
regionMatches(CharSequence cs,
boolean ignoreCase,
int thisStart,
CharSequence substring,
int start,
int length)
Green implementation of regionMatches.
|
static String |
trim(String str)
Removes control characters (char <= 32) from both
ends of this String, handling
null by returning null. |
public static boolean isEmpty(CharSequence cs)
Checks if a CharSequence is empty ("") or null.
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false
StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
NOTE: This method changed in Lang version 2.0. It no longer trims the CharSequence. That functionality is available in isBlank().
cs - the CharSequence to check, may be nulltrue if the CharSequence is empty or nullpublic static boolean isBlank(CharSequence cs)
Checks if a CharSequence is whitespace, empty ("") or null.
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
cs - the CharSequence to check, may be nulltrue if the CharSequence is null, empty or whitespacepublic static String trim(String str)
Removes control characters (char <= 32) from both
ends of this String, handling null by returning null.
The String is trimmed using String.trim().
Trim removes start and end characters <= 32.
StringUtils.trim(null) = null
StringUtils.trim("") = ""
StringUtils.trim(" ") = ""
StringUtils.trim("abc") = "abc"
StringUtils.trim(" abc ") = "abc"
str - the String to be trimmed, may be nullnull if null String inputpublic static boolean equals(CharSequence cs1, CharSequence cs2)
Compares two CharSequences, returning true if they represent
equal sequences of characters.
nulls are handled without exceptions. Two null
references are considered to be equal. The comparison is case sensitive.
StringUtils.equals(null, null) = true
StringUtils.equals(null, "abc") = false
StringUtils.equals("abc", null) = false
StringUtils.equals("abc", "abc") = true
StringUtils.equals("abc", "ABC") = false
cs1 - the first CharSequence, may be nullcs2 - the second CharSequence, may be nulltrue if the CharSequences are equal (case-sensitive), or both nullObject.equals(Object)public static boolean regionMatches(CharSequence cs, boolean ignoreCase, int thisStart, CharSequence substring, int start, int length)
cs - the CharSequence to be processedignoreCase - whether or not to be case insensitivethisStart - the index to start on the cs CharSequencesubstring - the CharSequence to be looked forstart - the index to start on the substring CharSequencelength - character length of the regionCopyright © 2018–2020 Alibaba Group. All rights reserved.