public class StringUtils extends Object
| 构造器和说明 |
|---|
StringUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
equals(String str1,
String str2) |
static int |
getNumber(String text) |
static boolean |
isBlank(String str) |
static boolean |
isEmpty(String str)
Checks if a String is empty ("") or null.
|
static boolean |
isExistBlank(String... strs) |
static boolean |
isNotBlank(String str) |
static boolean |
isNotEmpty(String str)
Checks if a String is not empty ("") and not null.
|
static boolean |
isNumeric(String str)
Checks if the String contains only unicode digits.
|
static String |
join(Object[] array,
char separator) |
static String |
join(Object[] array,
char separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String
containing the provided list of elements.
|
static void |
main(String[] args) |
static String |
substringBetween(String str,
String open,
String close) |
public static boolean isBlank(String str)
public static boolean isExistBlank(String... strs)
public static boolean isNumeric(String str)
Checks if the String contains only unicode digits. A decimal point is not a unicode digit and returns false.
null will return false.
An empty String ("") will return true.
StringUtils.isNumeric(null) = false
StringUtils.isNumeric("") = true
StringUtils.isNumeric(" ") = false
StringUtils.isNumeric("123") = true
StringUtils.isNumeric("12 3") = false
StringUtils.isNumeric("ab2c") = false
StringUtils.isNumeric("12-3") = false
StringUtils.isNumeric("12.3") = false
str - the String to check, may be nulltrue if only contains digits, and is non-nullpublic static int getNumber(String text) throws NumberFormatException
public static boolean isEmpty(String str)
Checks if a String 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 String. That functionality is available in isBlank().
str - the String to check, may be nulltrue if the String is empty or nullpublic static boolean isNotEmpty(String str)
Checks if a String is not empty ("") and not null.
StringUtils.isNotEmpty(null) = false
StringUtils.isNotEmpty("") = false
StringUtils.isNotEmpty(" ") = true
StringUtils.isNotEmpty("bob") = true
StringUtils.isNotEmpty(" bob ") = true
str - the String to check, may be nulltrue if the String is not empty and not nullpublic static boolean isNotBlank(String str)
public static String join(Object[] array, char separator, int startIndex, int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
No delimiter is added before or after the list. Null objects or empty strings within the array are represented by empty strings.
StringUtils.join(null, *) = null StringUtils.join([], *) = "" StringUtils.join([null], *) = "" StringUtils.join(["a", "b", "c"], ';') = "a;b;c" StringUtils.join(["a", "b", "c"], null) = "abc" StringUtils.join([null, "", "a"], ';') = ";;a"
array - the array of values to join together, may be nullseparator - the separator character to usestartIndex - the first index to start joining from. It is
an error to pass in an end index past the end of the arrayendIndex - the index to stop joining from (exclusive). It is
an error to pass in an end index past the end of the arraynull if null array inputpublic static void main(String[] args)
Copyright © 2019. All rights reserved.