类 StringUtils
- java.lang.Object
-
- com.alibaba.nacos.api.utils.StringUtils
-
public class StringUtils extends java.lang.ObjectStringUtils. copy from apache common-lang3.- 作者:
- lin-mt
-
-
字段概要
字段 修饰符和类型 字段 说明 static java.lang.StringEMPTYThe empty String"".
-
构造器概要
构造器 构造器 说明 StringUtils()
-
方法概要
所有方法 静态方法 具体方法 修饰符和类型 方法 说明 static booleanequals(java.lang.CharSequence cs1, java.lang.CharSequence cs2)Compares two CharSequences, returningtrueif they represent equal sequences of characters.static booleanisBlank(java.lang.CharSequence cs)Checks if a CharSequence is whitespace, empty ("") or null.static booleanisEmpty(java.lang.CharSequence cs)Checks if a CharSequence is empty ("") or null.static booleanregionMatches(java.lang.CharSequence cs, boolean ignoreCase, int thisStart, java.lang.CharSequence substring, int start, int length)Green implementation of regionMatches.static java.lang.Stringtrim(java.lang.String str)Removes control characters (char <= 32) from both ends of this String, handlingnullby returningnull.
-
-
-
字段详细资料
-
EMPTY
public static final java.lang.String EMPTY
The empty String"".- 从以下版本开始:
- 2.0
- 另请参阅:
- 常量字段值
-
-
方法详细资料
-
isEmpty
public static boolean isEmpty(java.lang.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 ") = falseNOTE: 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 null- 返回:
trueif the CharSequence is empty or null- 从以下版本开始:
- 3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence)
-
isBlank
public static boolean isBlank(java.lang.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 null- 返回:
trueif the CharSequence is null, empty or whitespace- 从以下版本开始:
- 2.0, 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
-
trim
public static java.lang.String trim(java.lang.String str)
Removes control characters (char <= 32) from both ends of this String, handling
nullby returningnull.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 null- 返回:
- the trimmed string,
nullif null String input
-
equals
public static boolean equals(java.lang.CharSequence cs1, java.lang.CharSequence cs2)Compares two CharSequences, returning
trueif they represent equal sequences of characters.nulls are handled without exceptions. Twonullreferences 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 benullcs2- the second CharSequence, may benull- 返回:
trueif the CharSequences are equal (case-sensitive), or bothnull- 从以下版本开始:
- 3.0 Changed signature from equals(String, String) to equals(CharSequence, CharSequence)
- 另请参阅:
Object.equals(Object)
-
regionMatches
public static boolean regionMatches(java.lang.CharSequence cs, boolean ignoreCase, int thisStart, java.lang.CharSequence substring, int start, int length)Green implementation of regionMatches.- 参数:
cs- theCharSequenceto be processedignoreCase- whether or not to be case insensitivethisStart- the index to start on thecsCharSequencesubstring- theCharSequenceto be looked forstart- the index to start on thesubstringCharSequencelength- character length of the region- 返回:
- whether the region matched
-
-