Java Collection Join joinTogether(Collection items, String delim)

Here you can find the source of joinTogether(Collection items, String delim)

Description

join Together

License

Apache License

Return

a delimited string containing the specified items

Declaration

public static String joinTogether(Collection<String> items, String delim) 

Method Source Code

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

import java.util.Collection;
import java.util.Iterator;

public class Main {
    /**//from   w ww.  ja v  a 2 s.  co m
     * @return a delimited string containing the specified items
     */
    public static String joinTogether(Collection<String> items, String delim) {
        StringBuffer ret = new StringBuffer();

        for (Iterator<String> it = items.iterator(); it.hasNext();) {
            ret.append(it.next());
            if (it.hasNext()) {
                ret.append(delim);
            }
        }

        return ret.toString();
    }
}

Related

  1. joinStrings(Collection names)
  2. joinStrings(Collection strings)
  3. joinStrings(String delim, Collection strs)
  4. joinStringValues(Collection values)
  5. joinTo(Collection data, String sep, StringBuilder sb)
  6. joinToStringBuilder(Collection collection, String separator)
  7. joinValues(Collection values, String separator)
  8. roundjoin(Collection s, String delimiter)
  9. stringJoin(Collection list, String delim)

  10. HOME | Copyright © www.java2s.com 2016