Java Collection to String toStringWithDelimiters(Collection objects, String delim)

Here you can find the source of toStringWithDelimiters(Collection objects, String delim)

Description

to String With Delimiters

License

LGPL

Declaration

public static String toStringWithDelimiters(Collection objects, String delim) 

Method Source Code


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

import java.util.*;

public class Main {
    public static String toStringWithDelimiters(Collection objects, String delim) {
        StringBuffer buffer = new StringBuffer();
        int index = 0;
        for (Object obj : objects) {
            if (index++ > 0)
                buffer.append(delim);/*from w w  w .  jav a  2s.  c  om*/
            buffer.append(obj);
        }
        return buffer.toString();
    }
}

Related

  1. toString(String[] collection, char separator)
  2. toStrings(Collection vals)
  3. toStrings(Collection c)
  4. toStrings(Collection objects)
  5. toStrings(final Collection stringCollection)
  6. toStringWithSeparator(Collection collection, String separator)