Class StringUtils
java.lang.Object
org.apache.tomcat.util.buf.StringUtils
Utility methods to build a separated list from a given set (not java.util.Set) of inputs and return that list as a
string or append it to an existing StringBuilder. If the given set is null or empty, an empty string will be
returned.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidjoin(Iterable<String> iterable, char separator, StringBuilder sb) Joins the elements of an iterable with the specified separator and appends the result to the given StringBuilder.static <T> voidjoin(Iterable<T> iterable, char separator, Function<T, String> function, StringBuilder sb) Joins the elements of an iterable using the specified separator and function, and appends the result to the given StringBuilder.static StringJoins the elements of a string array with a comma separator.static voidjoin(String[] array, char separator, StringBuilder sb) Joins the elements of a string array with the specified separator and appends the result to the given StringBuilder.static StringJoins two strings with a comma separator.static Stringjoin(Collection<String> collection) Joins the elements of a collection with a comma separator.static Stringjoin(Collection<String> collection, char separator) Joins the elements of a collection with the specified separator.static <T> voidjoin(T[] array, char separator, Function<T, String> function, StringBuilder sb) Joins the elements of an array using the specified separator and function, and appends the result to the given StringBuilder.static String[]Splits a comma-separated string into an array of String values.
-
Method Details
-
join
-
join
-
join
Joins the elements of a string array with the specified separator and appends the result to the given StringBuilder.- Parameters:
array- the array of strings to joinseparator- the separator charactersb- the StringBuilder to append to
-
join
Joins the elements of a collection with a comma separator.- Parameters:
collection- the collection of strings to join- Returns:
- the joined string
-
join
Joins the elements of a collection with the specified separator.- Parameters:
collection- the collection of strings to joinseparator- the separator character- Returns:
- the joined string
-
join
Joins the elements of an iterable with the specified separator and appends the result to the given StringBuilder.- Parameters:
iterable- the iterable of strings to joinseparator- the separator charactersb- the StringBuilder to append to
-
join
public static <T> void join(T[] array, char separator, Function<T, String> function, StringBuilder sb) Joins the elements of an array using the specified separator and function, and appends the result to the given StringBuilder.- Type Parameters:
T- the element type- Parameters:
array- the array to joinseparator- the separator characterfunction- the function to apply to each elementsb- the StringBuilder to append to
-
join
public static <T> void join(Iterable<T> iterable, char separator, Function<T, String> function, StringBuilder sb) Joins the elements of an iterable using the specified separator and function, and appends the result to the given StringBuilder.- Type Parameters:
T- the element type- Parameters:
iterable- the iterable to joinseparator- the separator characterfunction- the function to apply to each elementsb- the StringBuilder to append to
-
splitCommaSeparated
-