Java Collection Join join(Collection c, String joinSymbol)

Here you can find the source of join(Collection c, String joinSymbol)

Description

join

License

LGPL

Declaration

public static String join(Collection<String> c, String joinSymbol) 

Method Source Code


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

import java.util.Collection;

public class Main {

    public static String join(Collection<String> c, String joinSymbol) {
        StringBuffer sb = new StringBuffer("");
        if (c != null) {
            for (String text : c) {
                sb.append(text).append(joinSymbol);
            }//from  w  ww.j  a v a  2s . c  o  m
            int sblen = sb.length();
            int symlen = joinSymbol.length();
            if (sblen > symlen) {
                sb.delete(sblen - symlen, sblen);
            }
        }
        return sb.toString();
    }
}

Related

  1. join(Collection collection, String separator)
  2. join(Collection data)
  3. join(Collection c, String separator)
  4. join(Collection args, String delimeter)
  5. join(Collection c)
  6. join(Collection coll, String delimiter)
  7. join(Collection coll, String delimiter)
  8. join(Collection collection)
  9. join(Collection collection)