Klasse StringUtils
- Autor:
- matthias.drummer
-
Feldübersicht
Felder -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic StringdefaultString(String str) Returns either the passed in String, or if the String isnull, an empty String ("").static StringdefaultString(String str, String defaultStr) Returns either the passed in String, or if the String isnull, the value ofdefaultStr.static booleanisBlank(CharSequence cs) Checks if a CharSequence is empty (""), null or whitespace only.static StringJoins the elements of the providedIterableinto a single String containing the provided elements.static StringJoins the elements of the provided array into a single String containing the provided list of elements.static StringJoins the elements of the provided array into a single String containing the provided list of elements.static StringJoins the elements of the providedIteratorinto a single String containing the provided elements.static intlength(CharSequence cs) Gets a CharSequence length or0if the CharSequence isnull.
-
Felddetails
-
EMPTY
The empty String"".- Seit:
- 2.0
- Siehe auch:
-
-
Methodendetails
-
defaultString
Returns either the passed in String, or if the String is
null, an empty String ("").StringUtils.defaultString(null) = "" StringUtils.defaultString("") = "" StringUtils.defaultString("bat") = "bat"- Parameter:
str- the String to check, may be null- Gibt zurück:
- the passed in String, or the empty String if it
was
null - Siehe auch:
-
defaultString
Returns either the passed in String, or if the String is
null, the value ofdefaultStr.StringUtils.defaultString(null, "NULL") = "NULL" StringUtils.defaultString("", "NULL") = "" StringUtils.defaultString("bat", "NULL") = "bat"- Parameter:
str- the String to check, may be nulldefaultStr- the default String to return if the input isnull, may be null- Gibt zurück:
- the passed in String, or the default if it was
null - Siehe auch:
-
join
Joins the elements of the provided
Iterableinto a single String containing the provided elements.No delimiter is added before or after the list. A
nullseparator is the same as an empty String ("").See the examples here:
join(Object[], String).- Parameter:
iterable- theIterableproviding the values to join together, may be nullseparator- the separator character to use, null treated as ""- Gibt zurück:
- the joined String,
nullif null iterator input - Seit:
- 2.3
-
join
Joins the elements of the provided
Iteratorinto a single String containing the provided elements.No delimiter is added before or after the list. A
nullseparator is the same as an empty String ("").See the examples here:
join(Object[], String).- Parameter:
iterator- theIteratorof values to join together, may be nullseparator- the separator character to use, null treated as ""- Gibt zurück:
- the joined String,
nullif null iterator input
-
join
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. A
nullseparator is the same as an empty String (""). 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(["a", "b", "c"], "") = "abc" StringUtils.join([null, "", "a"], ',') = ",,a"
- Parameter:
array- the array of values to join together, may be nullseparator- the separator character to use, null treated as ""- Gibt zurück:
- the joined String,
nullif null array input
-
join
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. A
nullseparator is the same as an empty String (""). 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"], "--", 0, 3) = "a--b--c" StringUtils.join(["a", "b", "c"], "--", 1, 3) = "b--c" StringUtils.join(["a", "b", "c"], "--", 2, 3) = "c" StringUtils.join(["a", "b", "c"], "--", 2, 2) = "" StringUtils.join(["a", "b", "c"], null, 0, 3) = "abc" StringUtils.join(["a", "b", "c"], "", 0, 3) = "abc" StringUtils.join([null, "", "a"], ',', 0, 3) = ",,a"
- Parameter:
array- the array of values to join together, may be nullseparator- the separator character to use, null treated as ""startIndex- the first index to start joining from.endIndex- the index to stop joining from (exclusive).- Gibt zurück:
- the joined String,
nullif null array input; or the empty string ifendIndex - startIndex <= 0. The number of joined entries is given byendIndex - startIndex - Löst aus:
ArrayIndexOutOfBoundsException- ife
startIndex < 0or
startIndex >= array.length()or
endIndex < 0or
endIndex > array.length()
-
isBlank
Checks if a CharSequence is empty (""), null or whitespace only.
Whitespace is defined by
Character.isWhitespace(char).StringUtils.isBlank(null) = true StringUtils.isBlank("") = true StringUtils.isBlank(" ") = true StringUtils.isBlank("bob") = false StringUtils.isBlank(" bob ") = false- Parameter:
cs- the CharSequence to check, may be null- Gibt zurück:
trueif the CharSequence is null, empty or whitespace only- Seit:
- 2.0, 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
-
length
Gets a CharSequence length or0if the CharSequence isnull.- Parameter:
cs- a CharSequence ornull- Gibt zurück:
- CharSequence length or
0if the CharSequence isnull. - Seit:
- 2.4, 3.0 Changed signature from length(String) to length(CharSequence)
-