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

StringinvertPhoneNumber(String storedNumber, String joinString)
invert Phone Number
String prefix = String.join("", Arrays.asList("0", storedNumber.substring(2, 4)));
String midnumbers, finalnumbers;
try {
    midnumbers = storedNumber.substring(4, 7);
    finalnumbers = storedNumber.substring(7, 11);
} catch (Exception e) { 
    midnumbers = storedNumber.substring(4);
    finalnumbers = "";
...
StringJoin(ArrayList list, String delimiter)
This method converts a list of String objects to a single String representation and inserts a delimiter between each object.
if (list.isEmpty())
    return "";
StringBuilder sb = new StringBuilder();
for (String x : list)
    sb.append(x + delimiter);
sb.delete(sb.length() - delimiter.length(), sb.length());
return sb.toString();
Stringjoin(boolean endSlash, Collection paths)
join
if (paths == null || paths.isEmpty()) {
    return null;
boolean prevLastSlash = false;
StringBuilder buffer = new StringBuilder();
for (String param : paths) {
    if (param == null)
        continue;
...
Stringjoin(Collection collection, String separator)
Join an collection of objects with a separator that appears after every instance in the list -including at the end
return join(collection, separator, true);
Stringjoin(Collection items, String delimiter)
Returns all items, concatenated as a string with each of the entries divided by the delimiter.
return join(items, delimiter, 0, items.size());
Stringjoin(Enumeration enumeration, String s)
join
StringBuffer stringbuffer = new StringBuffer();
while (enumeration.hasMoreElements()) {
    String s1 = (String) enumeration.nextElement();
    stringbuffer.append(s1);
    if (enumeration.hasMoreElements()) {
        stringbuffer.append(s);
return stringbuffer.toString();
Stringjoin(Enumeration values, CharSequence separator)
Concatenates all of the strings in an Enumeration.
StringBuilder builder = new StringBuilder();
CharSequence prefix = "";
while (values.hasMoreElements()) {
    builder.append(prefix);
    builder.append(values.nextElement().toString());
    prefix = separator;
return builder.toString();
...
Stringjoin(final Collection input, final String link)
Join parts with link.
final StringBuilder builder = new StringBuilder(Math.max(300, input.size() * 10));
boolean first = true;
for (final Object obj : input) {
    if (!first)
        builder.append(link);
    builder.append(obj.toString());
    first = false;
return builder.toString();
Stringjoin(final String sep, final Iterable strs)
Join the given strings, separated by the given separator.
final StringBuilder buf = new StringBuilder();
String prefix = "";
for (final String str : strs) {
    buf.append(prefix).append(str);
    prefix = sep;
return buf.toString();
Stringjoin(final String separator, final Collection objs)
join
if (objs.size() == 0) {
    return "";
boolean notFirst = false;
final StringBuilder ret = new StringBuilder();
for (final Object obj : objs) {
    if (notFirst) {
        ret.append(separator);
...