public abstract class StringUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String[] |
EMPTY_STRING_ARRAY
An empty immutable
String array. |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
areNotEmpty(String... values)
检查指定的字符串列表是否不为空。
|
static String |
escapeXml(String value)
XML字符转义包括(<,>,',&,")五个字符.
|
static String |
formatDateTime(Date date)
对日期进行字符串格式化,采用yyyy-MM-dd HH:mm:ss的格式。
|
static String |
formatDateTime(Date date,
String pattern)
对日期进行字符串格式化,采用指定的格式。
|
static Set<String> |
getClassProperties(Class<?> clazz,
boolean isGet)
获取类的get/set属性名称集合。
|
static boolean |
isDigits(String str)
Checks whether the
String contains only
digit characters. |
static boolean |
isEmpty(String value)
检查指定的字符串是否为空。
|
static boolean |
isIpInRange(String ipAddr,
String cidrAddr)
判断指定的IP地址是否在IP段里面。
|
static boolean |
isNumeric(Object obj)
检查对象是否为数字型字符串,包含负数开头的。
|
static void |
join(Appendable buf,
Iterable<?> objs,
String sep)
将列表中的对象连接起来。
|
static String |
join(Iterable<?> objs,
String sep)
将列表中的对象连接成字符串
|
static void |
join(StringBuilder buf,
Iterable<?> objs,
String sep)
将列表中的对象连接起来。
|
static Date |
parseDateTime(String str)
把字符串解释为日期对象,采用yyyy-MM-dd HH:mm:ss的格式。
|
static String[] |
split(String str,
char separatorChar)
Splits the provided text into an array, separator specified.
|
static String[] |
split(String str,
String separatorChars)
Splits the provided text into an array, separators specified.
|
static String |
toCamelStyle(String name)
把名称转换为首字母小写的驼峰形式。
|
static String |
toUnderlineStyle(String name)
把名称转换为小写加下划线的形式。
|
static String |
unicodeToChinese(String unicode)
把通用字符编码的字符串转化为汉字编码。
|
public static final String[] EMPTY_STRING_ARRAY
String array.public static boolean isEmpty(String value)
value - 待检查的字符串public static boolean isNumeric(Object obj)
public static boolean areNotEmpty(String... values)
public static String escapeXml(String value)
value - 所需转义的字符串public static Set<String> getClassProperties(Class<?> clazz, boolean isGet)
clazz - 类isGet - 是否获取读方法,true为读方法,false为写方法public static boolean isDigits(String str)
Checks whether the String contains only
digit characters.
Null and empty String will return
false.
str - the String to checktrue if str contains only unicode numericpublic static String[] split(String str, char separatorChar)
Splits the provided text into an array, separator specified. This is an alternative to using StringTokenizer.
The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.
A null input String returns null.
StringUtils.split(null, *) = null
StringUtils.split("", *) = []
StringUtils.split("a.b.c", '.') = ["a", "b", "c"]
StringUtils.split("a..b.c", '.') = ["a", "b", "c"]
StringUtils.split("a:b:c", '.') = ["a:b:c"]
StringUtils.split("a b c", ' ') = ["a", "b", "c"]
str - the String to parse, may be nullseparatorChar - the character used as the delimiternull if null String inputpublic static String[] split(String str, String separatorChars)
Splits the provided text into an array, separators specified. This is an alternative to using StringTokenizer.
The separator is not included in the returned String array. Adjacent separators are treated as one separator. For more control over the split use the StrTokenizer class.
A null input String returns null.
A null separatorChars splits on whitespace.
StringUtils.split(null, *) = null
StringUtils.split("", *) = []
StringUtils.split("abc def", null) = ["abc", "def"]
StringUtils.split("abc def", " ") = ["abc", "def"]
StringUtils.split("abc def", " ") = ["abc", "def"]
StringUtils.split("ab:cd:ef", ":") = ["ab", "cd", "ef"]
str - the String to parse, may be nullseparatorChars - the characters used as the delimiters,
null splits on whitespacenull if null String inputpublic static boolean isIpInRange(String ipAddr, String cidrAddr)
ipAddr - IP地址cidrAddr - 用CIDR表示法的IP段信息public static void join(StringBuilder buf, Iterable<?> objs, String sep)
public static void join(Appendable buf, Iterable<?> objs, String sep) throws IOException
IOExceptionCopyright © 2020. All rights reserved.