Java Collection Join stringJoin(java.util.Collection s, String delimiter)

Here you can find the source of stringJoin(java.util.Collection s, String delimiter)

Description

string Join

License

BSD License

Declaration

public static String stringJoin(java.util.Collection<?> s, String delimiter) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    public static String stringJoin(java.util.Collection<?> s, String delimiter) {
        StringBuilder builder = new StringBuilder();
        java.util.Iterator<?> iter = s.iterator();
        while (iter.hasNext()) {
            builder.append(iter.next());
            if (!iter.hasNext()) {
                break;
            }//from  w  w  w  .ja  va2s  .  co  m
            builder.append(delimiter);
        }
        return builder.toString();
    }
}

Related

  1. joinTogether(Collection items, String delim)
  2. joinToStringBuilder(Collection collection, String separator)
  3. joinValues(Collection values, String separator)
  4. roundjoin(Collection s, String delimiter)
  5. stringJoin(Collection list, String delim)