类 StringUtils
- 从以下版本开始:
- 1.2.5
- 作者:
- xiemalin
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static Stringcapitalize(String str) Capitalizes a String changing the first letter to title case as perCharacter.toTitleCase(char).static booleanCheck if a String ends with a specified suffix.static booleanendsWithIgnoreCase(String str, String suffix) Case insensitive check if a String ends with a specified suffix.static StringescapeBytes(byte[] input) Like#escapeBytes(ByteString), but used for byte array.static voidescapeJava(Writer out, String str) Escapes the characters in aStringusing Java String rules to aWriter.static StringescapeJava(String str) Escapes the characters in aStringusing Java String rules.static booleanChecks if an array of Objects is empty ornull.static booleanChecks if a String is empty ("") or null.static StringRemoves a substring only if it is at the end of a source string, otherwise returns the source string.static StringremoveEndIgnoreCase(String str, String remove) Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.static StringremoveStart(String str, String remove) Removes a substring only if it is at the begining of a source string, otherwise returns the source string.static StringremoveStartIgnoreCase(String str, String remove) Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.static String[]Splits the provided text into an array, using whitespace as the separator.static String[]Splits the provided text into an array, separator specified.static String[]Splits the provided text into an array, separators specified.static String[]Splits the provided text into an array with a maximum length, separators specified.static String[]splitByWholeSeparator(String str, String separator) Splits the provided text into an array, separator string specified.static String[]splitByWholeSeparator(String str, String separator, int max) Splits the provided text into an array, separator string specified.static String[]splitByWholeSeparatorPreserveAllTokens(String str, String separator) Splits the provided text into an array, separator string specified.static String[]splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max) Splits the provided text into an array, separator string specified.static booleanstartsWith(String str, String prefix) Check if a String starts with a specified prefix.static booleanstartsWithAny(String string, String[] searchStrings) Check if a String starts with any of an array of specified strings.static booleanstartsWithIgnoreCase(String str, String prefix) Case insensitive check if a String starts with a specified prefix.static intstringToInt(String str, int defaultValue) 已过时。static StringsubstringAfterLast(String str, String separator) Gets the substring after the last occurrence of a separator.static StringsubstringBefore(String str, String separator) Gets the substring before the first occurrence of a separator.static StringsubstringBeforeLast(String str, String separator) Gets the substring before the last occurrence of a separator.static intConvert aStringto anint, returningzeroif the conversion fails.static intConvert aStringto anint, returning a default value if the conversion fails.static longConvert aStringto anlong, returning a default value if the conversion fails.static longConvert aStringto anlong, returning a default value if the conversion fails.static StringtoLowerCase(String str) To lower case.static StringtrimToEmpty(String str) Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it isnull.static Stringuncapitalize(String str) Uncapitalizes a String, changing the first character to lower case as perCharacter.toLowerCase(int).static voidunescapeJava(Writer out, String str) Unescapes any Java literals found in theStringto aWriter.static StringunescapeJava(String str) Unescapes any Java literals found in theString.
-
字段详细资料
-
构造器详细资料
-
StringUtils
public StringUtils()
-
-
方法详细资料
-
endsWith
Check if a String ends with a specified suffix.
nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case sensitive.StringUtils.endsWith(null, null) = true StringUtils.endsWith(null, "abcdef") = false StringUtils.endsWith("def", null) = false StringUtils.endsWith("def", "abcdef") = true StringUtils.endsWith("def", "ABCDEF") = false- 参数:
str- the String to check, may be nullsuffix- the suffix to find, may be null- 返回:
trueif the String ends with the suffix, case sensitive, or bothnull- 从以下版本开始:
- 2.4
- 另请参阅:
-
endsWithIgnoreCase
Case insensitive check if a String ends with a specified suffix.
nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case insensitive.StringUtils.endsWithIgnoreCase(null, null) = true StringUtils.endsWithIgnoreCase(null, "abcdef") = false StringUtils.endsWithIgnoreCase("def", null) = false StringUtils.endsWithIgnoreCase("def", "abcdef") = true StringUtils.endsWithIgnoreCase("def", "ABCDEF") = false- 参数:
str- the String to check, may be nullsuffix- the suffix to find, may be null- 返回:
trueif the String ends with the suffix, case insensitive, or bothnull- 从以下版本开始:
- 2.4
- 另请参阅:
-
removeEnd
Removes a substring only if it is at the end of a source string, otherwise returns the source string.
A
nullsource string will returnnull. An empty ("") source string will return the empty string. Anullsearch string will return the source string.StringUtils.removeEnd(null, *) = null StringUtils.removeEnd("", *) = "" StringUtils.removeEnd(*, null) = * StringUtils.removeEnd("www.domain.com", ".com.") = "www.domain.com" StringUtils.removeEnd("www.domain.com", ".com") = "www.domain" StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com" StringUtils.removeEnd("abc", "") = "abc"- 参数:
str- the source String to search, may be nullremove- the String to search for and remove, may be null- 返回:
- the substring with the string removed if found,
nullif null String input - 从以下版本开始:
- 2.1
-
removeEndIgnoreCase
Case insensitive removal of a substring if it is at the end of a source string, otherwise returns the source string.
A
nullsource string will returnnull. An empty ("") source string will return the empty string. Anullsearch string will return the source string.StringUtils.removeEnd(null, *) = null StringUtils.removeEnd("", *) = "" StringUtils.removeEnd(*, null) = * StringUtils.removeEnd("www.domain.com", ".com.") = "www.domain.com." StringUtils.removeEnd("www.domain.com", ".com") = "www.domain" StringUtils.removeEnd("www.domain.com", "domain") = "www.domain.com" StringUtils.removeEnd("abc", "") = "abc"- 参数:
str- the source String to search, may be nullremove- the String to search for (case insensitive) and remove, may be null- 返回:
- the substring with the string removed if found,
nullif null String input - 从以下版本开始:
- 2.4
-
isEmpty
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 ") = falseNOTE: 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 null- 返回:
trueif the String is empty or null
-
removeStart
Removes a substring only if it is at the begining of a source string, otherwise returns the source string.
A
nullsource string will returnnull. An empty ("") source string will return the empty string. Anullsearch string will return the source string.StringUtils.removeStart(null, *) = null StringUtils.removeStart("", *) = "" StringUtils.removeStart(*, null) = * StringUtils.removeStart("www.domain.com", "www.") = "domain.com" StringUtils.removeStart("domain.com", "www.") = "domain.com" StringUtils.removeStart("www.domain.com", "domain") = "www.domain.com" StringUtils.removeStart("abc", "") = "abc"- 参数:
str- the source String to search, may be nullremove- the String to search for and remove, may be null- 返回:
- the substring with the string removed if found,
nullif null String input - 从以下版本开始:
- 2.1
-
removeStartIgnoreCase
Case insensitive removal of a substring if it is at the begining of a source string, otherwise returns the source string.
A
nullsource string will returnnull. An empty ("") source string will return the empty string. Anullsearch string will return the source string.StringUtils.removeStartIgnoreCase(null, *) = null StringUtils.removeStartIgnoreCase("", *) = "" StringUtils.removeStartIgnoreCase(*, null) = * StringUtils.removeStartIgnoreCase("www.domain.com", "www.") = "domain.com" StringUtils.removeStartIgnoreCase("www.domain.com", "WWW.") = "domain.com" StringUtils.removeStartIgnoreCase("domain.com", "www.") = "domain.com" StringUtils.removeStartIgnoreCase("www.domain.com", "domain") = "www.domain.com" StringUtils.removeStartIgnoreCase("abc", "") = "abc"- 参数:
str- the source String to search, may be nullremove- the String to search for (case insensitive) and remove, may be null- 返回:
- the substring with the string removed if found,
nullif null String input - 从以下版本开始:
- 2.4
-
startsWith
Check if a String starts with a specified prefix.
nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case sensitive.StringUtils.startsWith(null, null) = true StringUtils.startsWith(null, "abcdef") = false StringUtils.startsWith("abc", null) = false StringUtils.startsWith("abc", "abcdef") = true StringUtils.startsWith("abc", "ABCDEF") = false- 参数:
str- the String to check, may be nullprefix- the prefix to find, may be null- 返回:
trueif the String starts with the prefix, case sensitive, or bothnull- 从以下版本开始:
- 2.4
- 另请参阅:
-
startsWithAny
Check if a String starts with any of an array of specified strings.
StringUtils.startsWithAny(null, null) = false StringUtils.startsWithAny(null, new String[] {"abc"}) = false StringUtils.startsWithAny("abcxyz", null) = false StringUtils.startsWithAny("abcxyz", new String[] {""}) = false StringUtils.startsWithAny("abcxyz", new String[] {"abc"}) = true StringUtils.startsWithAny("abcxyz", new String[] {null, "xyz", "abc"}) = true- 参数:
string- the String to check, may be nullsearchStrings- the Strings to find, may be null or empty- 返回:
trueif the String starts with any of the the prefixes, case insensitive, or bothnull- 从以下版本开始:
- 2.5
- 另请参阅:
-
startsWithIgnoreCase
Case insensitive check if a String starts with a specified prefix.
nulls are handled without exceptions. Twonullreferences are considered to be equal. The comparison is case insensitive.StringUtils.startsWithIgnoreCase(null, null) = true StringUtils.startsWithIgnoreCase(null, "abcdef") = false StringUtils.startsWithIgnoreCase("abc", null) = false StringUtils.startsWithIgnoreCase("abc", "abcdef") = true StringUtils.startsWithIgnoreCase("abc", "ABCDEF") = true- 参数:
str- the String to check, may be nullprefix- the prefix to find, may be null- 返回:
trueif the String starts with the prefix, case insensitive, or bothnull- 从以下版本开始:
- 2.4
- 另请参阅:
-
substringBefore
Gets the substring before the first occurrence of a separator. The separator is not returned.
A
nullstring input will returnnull. An empty ("") string input will return the empty string. Anullseparator will return the input string.StringUtils.substringBefore(null, *) = null StringUtils.substringBefore("", *) = "" StringUtils.substringBefore("abc", "a") = "" StringUtils.substringBefore("abcba", "b") = "a" StringUtils.substringBefore("abc", "c") = "ab" StringUtils.substringBefore("abc", "d") = "abc" StringUtils.substringBefore("abc", "") = "" StringUtils.substringBefore("abc", null) = "abc"- 参数:
str- the String to get a substring from, may be nullseparator- the String to search for, may be null- 返回:
- the substring before the first occurrence of the separator,
nullif null String input - 从以下版本开始:
- 2.0
-
substringBeforeLast
Gets the substring before the last occurrence of a separator. The separator is not returned.
A
nullstring input will returnnull. An empty ("") string input will return the empty string. An empty ornullseparator will return the input string.StringUtils.substringBeforeLast(null, *) = null StringUtils.substringBeforeLast("", *) = "" StringUtils.substringBeforeLast("abcba", "b") = "abc" StringUtils.substringBeforeLast("abc", "c") = "ab" StringUtils.substringBeforeLast("a", "a") = "" StringUtils.substringBeforeLast("a", "z") = "a" StringUtils.substringBeforeLast("a", null) = "a" StringUtils.substringBeforeLast("a", "") = "a"- 参数:
str- the String to get a substring from, may be nullseparator- the String to search for, may be null- 返回:
- the substring before the last occurrence of the separator,
nullif null String input - 从以下版本开始:
- 2.0
-
substringAfterLast
Gets the substring after the last occurrence of a separator. The separator is not returned.
A
nullstring input will returnnull. An empty ("") string input will return the empty string. An empty ornullseparator will return the empty string if the input string is notnull.StringUtils.substringAfterLast(null, *) = null StringUtils.substringAfterLast("", *) = "" StringUtils.substringAfterLast(*, "") = "" StringUtils.substringAfterLast(*, null) = "" StringUtils.substringAfterLast("abc", "a") = "bc" StringUtils.substringAfterLast("abcba", "b") = "a" StringUtils.substringAfterLast("abc", "c") = "" StringUtils.substringAfterLast("a", "a") = "" StringUtils.substringAfterLast("a", "z") = ""- 参数:
str- the String to get a substring from, may be nullseparator- the String to search for, may be null- 返回:
- the substring after the last occurrence of the separator,
nullif null String input - 从以下版本开始:
- 2.0
-
capitalize
Capitalizes a String changing the first letter to title case as per
Character.toTitleCase(char). No other letters are changed.For a word based algorithm, see
WordUtils#capitalize(String). Anullinput String returnsnull.StringUtils.capitalize(null) = null StringUtils.capitalize("") = "" StringUtils.capitalize("cat") = "Cat" StringUtils.capitalize("cAt") = "CAt"- 参数:
str- the String to capitalize, may be null- 返回:
- the capitalized String,
nullif null String input - 从以下版本开始:
- 2.0
- 另请参阅:
-
WordUtils#capitalize(String)uncapitalize(String)
-
escapeJava
Escapes the characters in a
Stringusing Java String rules.Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters
'\\'and't'.The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote must be escaped.
Example:
input string: He didn't say, "Stop!" output string: He didn't say, \"Stop!\"
- 参数:
str- String to escape values in, may be null- 返回:
- String with escaped values,
nullif null string input
-
escapeJava
Escapes the characters in a
Stringusing Java String rules to aWriter.A
nullstring input has no effect.- 参数:
out- Writer to write escaped string intostr- String to escape values in, may be null- 抛出:
IllegalArgumentException- if the Writer isnullIOException- if error occurs on underlying Writer- 另请参阅:
-
unescapeJava
Unescapes any Java literals found in the
String. For example, it will turn a sequence of'\'and'n'into a newline character, unless the'\'is preceded by another'\'.- 参数:
str- theStringto unescape, may be null- 返回:
- a new unescaped
String,nullif null string input
-
unescapeJava
Unescapes any Java literals found in the
Stringto aWriter.For example, it will turn a sequence of
'\'and'n'into a newline character, unless the'\'is preceded by another'\'.A
nullstring input has no effect.- 参数:
out- theWriterused to output unescaped charactersstr- theStringto unescape, may be null- 抛出:
IllegalArgumentException- if the Writer isnullIOException- if error occurs on underlying Writer
-
split
Splits the provided text into an array, using whitespace as the separator. Whitespace is defined by
Character.isWhitespace(char).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
nullinput String returnsnull.StringUtils.split(null) = null StringUtils.split("") = [] StringUtils.split("abc def") = ["abc", "def"] StringUtils.split("abc def") = ["abc", "def"] StringUtils.split(" abc ") = ["abc"]- 参数:
str- the String to parse, may be null- 返回:
- an array of parsed Strings,
nullif null String input
-
split
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
nullinput String returnsnull.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 delimiter- 返回:
- an array of parsed Strings,
nullif null String input - 从以下版本开始:
- 2.0
-
split
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
nullinput String returnsnull. AnullseparatorChars 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,nullsplits on whitespace- 返回:
- an array of parsed Strings,
nullif null String input
-
split
Splits the provided text into an array with a maximum length, separators specified.
The separator is not included in the returned String array. Adjacent separators are treated as one separator.
A
nullinput String returnsnull. AnullseparatorChars splits on whitespace.If more than
maxdelimited substrings are found, the last returned string includes all characters after the firstmax - 1returned strings (including separator characters).StringUtils.split(null, *, *) = null StringUtils.split("", *, *) = [] StringUtils.split("ab de fg", null, 0) = ["ab", "cd", "ef"] StringUtils.split("ab de fg", null, 0) = ["ab", "cd", "ef"] StringUtils.split("ab:cd:ef", ":", 0) = ["ab", "cd", "ef"] StringUtils.split("ab:cd:ef", ":", 2) = ["ab", "cd:ef"]- 参数:
str- the String to parse, may be nullseparatorChars- the characters used as the delimiters,nullsplits on whitespacemax- the maximum number of elements to include in the array. A zero or negative value implies no limit- 返回:
- an array of parsed Strings,
nullif null String input
-
splitByWholeSeparator
Splits the provided text into an array, separator string specified.
The separator(s) will not be included in the returned String array. Adjacent separators are treated as one separator.
A
nullinput String returnsnull. Anullseparator splits on whitespace.StringUtils.splitByWholeSeparator(null, *) = null StringUtils.splitByWholeSeparator("", *) = [] StringUtils.splitByWholeSeparator("ab de fg", null) = ["ab", "de", "fg"] StringUtils.splitByWholeSeparator("ab de fg", null) = ["ab", "de", "fg"] StringUtils.splitByWholeSeparator("ab:cd:ef", ":") = ["ab", "cd", "ef"] StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-") = ["ab", "cd", "ef"]- 参数:
str- the String to parse, may be nullseparator- String containing the String to be used as a delimiter,nullsplits on whitespace- 返回:
- an array of parsed Strings,
nullif null String was input
-
splitByWholeSeparator
Splits the provided text into an array, separator string specified. Returns a maximum of
maxsubstrings.The separator(s) will not be included in the returned String array. Adjacent separators are treated as one separator.
A
nullinput String returnsnull. Anullseparator splits on whitespace.StringUtils.splitByWholeSeparator(null, *, *) = null StringUtils.splitByWholeSeparator("", *, *) = [] StringUtils.splitByWholeSeparator("ab de fg", null, 0) = ["ab", "de", "fg"] StringUtils.splitByWholeSeparator("ab de fg", null, 0) = ["ab", "de", "fg"] StringUtils.splitByWholeSeparator("ab:cd:ef", ":", 2) = ["ab", "cd:ef"] StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", 5) = ["ab", "cd", "ef"] StringUtils.splitByWholeSeparator("ab-!-cd-!-ef", "-!-", 2) = ["ab", "cd-!-ef"]- 参数:
str- the String to parse, may be nullseparator- String containing the String to be used as a delimiter,nullsplits on whitespacemax- the maximum number of elements to include in the returned array. A zero or negative value implies no limit.- 返回:
- an array of parsed Strings,
nullif null String was input
-
splitByWholeSeparatorPreserveAllTokens
Splits the provided text into an array, separator string specified.
The separator is not included in the returned String array. Adjacent separators are treated as separators for empty tokens. For more control over the split use the StrTokenizer class.
A
nullinput String returnsnull. Anullseparator splits on whitespace.StringUtils.splitByWholeSeparatorPreserveAllTokens(null, *) = null StringUtils.splitByWholeSeparatorPreserveAllTokens("", *) = [] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null) = ["ab", "de", "fg"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null) = ["ab", "", "", "de", "fg"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab:cd:ef", ":") = ["ab", "cd", "ef"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-") = ["ab", "cd", "ef"]- 参数:
str- the String to parse, may be nullseparator- String containing the String to be used as a delimiter,nullsplits on whitespace- 返回:
- an array of parsed Strings,
nullif null String was input - 从以下版本开始:
- 2.4
-
splitByWholeSeparatorPreserveAllTokens
public static String[] splitByWholeSeparatorPreserveAllTokens(String str, String separator, int max) Splits the provided text into an array, separator string specified. Returns a maximum of
maxsubstrings.The separator is not included in the returned String array. Adjacent separators are treated as separators for empty tokens. For more control over the split use the StrTokenizer class.
A
nullinput String returnsnull. Anullseparator splits on whitespace.StringUtils.splitByWholeSeparatorPreserveAllTokens(null, *, *) = null StringUtils.splitByWholeSeparatorPreserveAllTokens("", *, *) = [] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null, 0) = ["ab", "de", "fg"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab de fg", null, 0) = ["ab", "", "", "de", "fg"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab:cd:ef", ":", 2) = ["ab", "cd:ef"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-", 5) = ["ab", "cd", "ef"] StringUtils.splitByWholeSeparatorPreserveAllTokens("ab-!-cd-!-ef", "-!-", 2) = ["ab", "cd-!-ef"]- 参数:
str- the String to parse, may be nullseparator- String containing the String to be used as a delimiter,nullsplits on whitespacemax- the maximum number of elements to include in the returned array. A zero or negative value implies no limit.- 返回:
- an array of parsed Strings,
nullif null String was input - 从以下版本开始:
- 2.4
-
escapeBytes
Like#escapeBytes(ByteString), but used for byte array. -
toInt
Convert a
Stringto anint, returningzeroif the conversion fails.If the string is
null,zerois returned.NumberUtils.toInt(null) = 0 NumberUtils.toInt("") = 0 NumberUtils.toInt("1") = 1- 参数:
str- the string to convert, may be null- 返回:
- the int represented by the string, or
zeroif conversion fails - 从以下版本开始:
- 2.1
-
stringToInt
已过时。UsetoInt(String, int)This method will be removed in Commons Lang 3.0Convert a
Stringto anint, returning a default value if the conversion fails.If the string is
null, the default value is returned.NumberUtils.stringToInt(null, 1) = 1 NumberUtils.stringToInt("", 1) = 1 NumberUtils.stringToInt("1", 0) = 1- 参数:
str- the string to convert, may be nulldefaultValue- the default value- 返回:
- the int represented by the string, or the default if conversion fails
-
toInt
Convert a
Stringto anint, returning a default value if the conversion fails.If the string is
null, the default value is returned.NumberUtils.toInt(null, 1) = 1 NumberUtils.toInt("", 1) = 1 NumberUtils.toInt("1", 0) = 1- 参数:
str- the string to convert, may be nulldefaultValue- the default value- 返回:
- the int represented by the string, or the default if conversion fails
- 从以下版本开始:
- 2.1
-
toLong
Convert a
Stringto anlong, returning a default value if the conversion fails.If the string is
null, the default value is returned.NumberUtils.toLong(null) = 0 NumberUtils.toLong("") = 0 NumberUtils.toLong("1") = 1- 参数:
str- the string to convert, may be null- 返回:
- the long represented by the string, or the default if conversion fails
- 从以下版本开始:
- 2.1
-
toLong
Convert a
Stringto anlong, returning a default value if the conversion fails.If the string is
null, the default value is returned.NumberUtils.toLong(null, 1) = 1 NumberUtils.toLong("", 1) = 1 NumberUtils.toLong("1", 0) = 1- 参数:
str- the string to convert, may be nulldefaultValue- the default value- 返回:
- the long represented by the string, or the default if conversion fails
- 从以下版本开始:
- 2.1
-
trimToEmpty
Removes control characters (char <= 32) from both ends of this String returning an empty String ("") if the String is empty ("") after the trim or if it is
null.The String is trimmed using
String.trim(). Trim removes start and end characters <= 32. To strip whitespace use#stripToEmpty(String).StringUtils.trimToEmpty(null) = "" StringUtils.trimToEmpty("") = "" StringUtils.trimToEmpty(" ") = "" StringUtils.trimToEmpty("abc") = "abc" StringUtils.trimToEmpty(" abc ") = "abc"- 参数:
str- the String to be trimmed, may be null- 返回:
- the trimmed String, or an empty String if
nullinput - 从以下版本开始:
- 2.0
-
uncapitalize
Uncapitalizes a String, changing the first character to lower case as per
Character.toLowerCase(int). No other characters are changed.For a word based algorithm, see
org.apache.commons.lang3.text.WordUtils#uncapitalize(String). Anullinput String returnsnull.StringUtils.uncapitalize(null) = null StringUtils.uncapitalize("") = "" StringUtils.uncapitalize("cat") = "cat" StringUtils.uncapitalize("Cat") = "cat" StringUtils.uncapitalize("CAT") = "cAT"- 参数:
str- the String to uncapitalize, may be null- 返回:
- the uncapitalized String,
nullif null String input - 从以下版本开始:
- 2.0
- 另请参阅:
-
org.apache.commons.lang3.text.WordUtils#uncapitalize(String)capitalize(String)
-
toLowerCase
To lower case.- 参数:
str- the str- 返回:
- the string
-
isEmpty
Checks if an array of Objects is empty or
null.- 参数:
array- the array to test- 返回:
trueif the array is empty ornull- 从以下版本开始:
- 2.1
-
toInt(String, int)This method will be removed in Commons Lang 3.0