public final class StringJoiner extends Object
| Modifier and Type | Field and Description |
|---|---|
static String |
EMPTY
The empty String
"". |
| Constructor and Description |
|---|
StringJoiner() |
| Modifier and Type | Method and Description |
|---|---|
static String |
join(byte[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(byte[] 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 String |
join(char[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(char[] 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 String |
join(double[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(double[] 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 String |
join(float[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(float[] 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 String |
join(int[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(int[] 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 String |
join(Iterable<?> iterable,
char separator)
Joins the elements of the provided
Iterable into a single String containing the provided elements. |
static String |
join(Iterable<?> iterable,
String separator)
Joins the elements of the provided
Iterable into a single String containing the provided elements. |
static String |
join(Iterator<?> iterator,
char separator)
Joins the elements of the provided
Iterator into a single String containing the provided elements. |
static String |
join(Iterator<?> iterator,
String separator)
Joins the elements of the provided
Iterator into a single String containing the provided elements. |
static String |
join(long[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(long[] 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 String |
join(Object[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
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 String |
join(Object[] array,
String separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(Object[] array,
String separator,
int startIndex,
int endIndex)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(short[] array,
char separator)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
static String |
join(short[] 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 <T> String |
join(T... elements)
Joins the elements of the provided array into a single String containing the provided list of elements.
|
public static final String EMPTY
"".public static <T> String join(T... elements)
No separator is added to the joined 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"]) = "abc" StringUtils.join([null, "", "a"]) = "a"
T - the specific type of values to join togetherelements - the values to join together, may be nullnull if null array inputpublic static String join(Object[] array, char separator)
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 usenull if null array inputpublic static String join(long[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(int[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(short[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(byte[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(char[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(float[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(double[] array, char separator)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
array - the array of values to join together, may be nullseparator - the separator character to usenull if null array inputpublic static String join(Object[] array, char separator, int startIndex, int endIndex)
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 String join(long[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(int[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(byte[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(short[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(char[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(double[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(float[] array, char separator, int startIndex, int endIndex)
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([1, 2, 3], ';') = "1;2;3" StringUtils.join([1, 2, 3], null) = "123"
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 String join(Object[] array, String separator)
No delimiter is added before or after the list. A null separator 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"
array - the array of values to join together, may be nullseparator - the separator character to use, null treated as ""null if null array inputpublic static String join(Object[] array, String separator, int startIndex, int endIndex)
No delimiter is added before or after the list. A null separator 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"
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).null if null array input; or the empty string if
endIndex - startIndex <= 0. The number of joined entries is given by endIndex - startIndexArrayIndexOutOfBoundsException - ife
startIndex < 0 or
startIndex >= array.length() or endIndex < 0 or endIndex > array.length()public static String join(Iterator<?> iterator, char separator)
Iterator into a single String containing the provided elements.
No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
See the examples here: join(Object[],char).
iterator - the Iterator of values to join together, may be nullseparator - the separator character to usenull if null iterator inputpublic static String join(Iterator<?> iterator, String separator)
Iterator into a single String containing the provided elements.
No delimiter is added before or after the list. A null separator is the same as an empty String ("").
See the examples here: join(Object[],String).
iterator - the Iterator of values to join together, may be nullseparator - the separator character to use, null treated as ""null if null iterator inputpublic static String join(Iterable<?> iterable, char separator)
Iterable into a single String containing the provided elements.
No delimiter is added before or after the list. Null objects or empty strings within the iteration are represented by empty strings.
See the examples here: join(Object[],char).
iterable - the Iterable providing the values to join together, may be nullseparator - the separator character to usenull if null iterator inputpublic static String join(Iterable<?> iterable, String separator)
Iterable into a single String containing the provided elements.
No delimiter is added before or after the list. A null separator is the same as an empty String ("").
See the examples here: join(Object[],String).
iterable - the Iterable providing the values to join together, may be nullseparator - the separator character to use, null treated as ""null if null iterator inputCopyright © 2012 Sven Strittmatter. All Rights Reserved.