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

MapjoinValues(Map map, String separator)
Joins each collection of values in a given Map into their String representation, with a given separator between each value.
if (map == null || map.isEmpty()) {
    return Collections.emptyMap();
LinkedHashMap<K, String> out = new LinkedHashMap<K, String>();
for (Map.Entry<K, V> e : map.entrySet()) {
    out.put(e.getKey(), join(e.getValue(), separator));
return out;
...
StringjoinWithSeparation(String a, String separator, String b)
Appends two strings, inserting separator if either is empty
if (a.length() == 0)
    return b;
if (b.length() == 0)
    return a;
return a + separator + b;
Stringmerge(ArrayList pArrayList, String pJoin)
merge
String lReturn = "";
if (pArrayList.size() > 0) {
    lReturn += (String) pArrayList.get(0);
    for (int i = 1; i < pArrayList.size(); i++) {
        lReturn += pJoin + (String) pArrayList.get(i);
return lReturn;
...
voidmergeDependencies(Set bundleDeps, List deps, Map disjointSets)
merge Dependencies
if (deps != null) {
    bundleDeps.addAll(deps);
    Iterator iter = deps.iterator();
    while (iter.hasNext()) {
        String name = (String) iter.next();
        mergeDependencies(bundleDeps, (List) disjointSets.get(name), disjointSets);
Stringprefixed_join(String padder, Vector v, boolean quoted)
prefixejoin
StringBuffer sb = new StringBuffer();
for (Iterator<String> iter = v.iterator(); iter.hasNext();) {
    sb.append(padder);
    if (quoted) {
        sb.append('"');
    sb.append((String) iter.next());
    if (quoted) {
...
Stringstrjoin(String sep, String... args)
Concatentate string, using a separator
return join(sep, args);
StringstrjoinNL(String... args)
strjoin with a newline as the separator
return join("\n", args);