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

Stringjoin(final String separator, final String... strings)
join
String output = "";
for (int i = 0; i < strings.length; i++) {
    String s = strings[i];
    output += s;
    if (i < strings.length - 1) {
        output += separator;
return output;
Stringjoin(final String... arguments)
join
return join(isEmpty((Object[]) arguments) ? null : Arrays.asList(arguments), SPACE);
Stringjoin(HashMap params, String separator)
join
if (separator == null || separator.equalsIgnoreCase("")) {
    throw new IllegalArgumentException("Missing separator!");
String output = "";
if (params != null) {
    for (String name : params.keySet()) {
        if (output.length() > 0) {
            output = output + separator;
...
Stringjoin(Iterable arr, String delimeter)
Concatenate a list of values together as a string.
StringBuilder str = new StringBuilder();
boolean first = true;
for (Object ob : arr) {
    if (first) {
        first = false;
    } else {
        str.append(delimeter);
    str.append(ob);
return str.toString();
Stringjoin(Iterable input)
Returns a comma-separated join of the strings in the input.
StringBuilder builder = new StringBuilder();
for (String item : input) {
    builder.append(item).append(", ");
if (builder.length() >= 2) {
    builder.setLength(builder.length() - 2);
return builder.toString();
...
Stringjoin(java.util.Collection strings, String delimiter)
Returns a string representation of 'strings' which contains all elements of 'strings' separated by 'delimiter'.
StringBuilder ans = new StringBuilder();
boolean first = true;
for (Object s : strings) {
    if (first)
        first = false;
    else
        ans.append(delimiter);
    ans.append(s);
...
Listjoin(Map map, String separator)
join
if (map == null) {
    return null;
List<String> list = new ArrayList<String>();
if (map == null || map.size() == 0) {
    return list;
for (Map.Entry<String, String> entry : map.entrySet()) {
...
Stringjoin(String connector, Object... objects)
join
StringBuffer sBuffer = new StringBuffer();
for (Object object : objects) {
    sBuffer.append(object).append(connector);
if (sBuffer.length() > 0) {
    sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length());
return sBuffer.toString();
...
Stringjoin(String delim, List strings)
join
StringBuilder builder = new StringBuilder();
if (strings != null) {
    for (String str : strings) {
        if (builder.length() > 0) {
            builder.append(delim).append(" ");
        builder.append(str);
return builder.toString();
Stringjoin(String delim, Object... objects)
Join a list of non-null objects with delim and return it as a string.
final StringBuilder b = new StringBuilder();
for (Object s : objects) {
    if (s != null) {
        if (b.length() > 0)
            b.append(delim);
        b.append(s.toString());
return b.toString();