Java Utililty Methods String Join

List of utility methods to do String Join

Description

The list of methods to do String Join are organized into topic(s).

Method

ListjoinedList(T first, T... others)
joined List
ArrayList<T> list = new ArrayList<T>();
list.add(first);
Collections.addAll(list, others);
return list;
StringjoinIterable(Iterable element, String separator)
join Iterable
List<String> list = new ArrayList<String>();
for (String each : element) {
    list.add(each);
return join(list, separator);
StringjoinMap(Map map)
join Map
if (map.isEmpty()) {
    return "";
StringBuilder stringBuilder = new StringBuilder();
boolean notFirst = false;
for (Map.Entry<?, ?> entry : map.entrySet()) {
    if (notFirst) {
        stringBuilder.append(',');
...
StringjoinMap(String keyValueSeperator, String recordSeperator, Map map)
join the key value pairs of a map into one string, i.e.
if (map.size() < 1) {
    return null;
String joinedKeyValues[] = new String[map.size()];
int index = 0;
for (L key : map.keySet()) {
    joinedKeyValues[index++] = String.format("%s%s%s", key.toString(), keyValueSeperator,
            map.get(key).toString());
...
voidJoinMaps(Map into, Map other)
Join Maps
if (other == null)
    return;
Iterator it = other.keySet().iterator();
while (it.hasNext()) {
    Object prot = it.next();
    into.put(prot, other.get(prot));
StringjoinPath(String part1, String part2)
join Path
final List<String> parts = new ArrayList<>();
addPathPart(parts, part1);
addPathPart(parts, part2);
return join(parts, "/");
StringjoinPaths(String... paths)
Concatenates multiple paths and separates them with '/'.

Consecutive slashes will be reduced to a single slash in the resulting string.

String result = listAsString(Arrays.asList(paths), "/");
result = result.replaceAll("/+", "/");
return result;
StringjoinRepeat(int size, String s, String delim)
join Repeat
return join(repeatList(size, s), delim);
String[]joinSplit(String record, String regex)
join Split
String[] split = record.split(regex);
Collection<String> elements = new ArrayList<String>();
for (int i = 1; i < split.length; i++) {
    regex = (regex.indexOf("|") != -1) ? regex.substring(0, regex.indexOf("|")) : regex;
    elements.add(regex + split[i]);
return elements.toArray(new String[0]);
StringjoinString(String separator, String... elements)
join String
return joinString(elements, separator);