Java Collection to String convertListToString(Collection list)

Here you can find the source of convertListToString(Collection list)

Description

convert List To String

License

Apache License

Declaration

private static <T> String convertListToString(Collection<T> list) 

Method Source Code

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

import java.util.Collection;

public class Main {
    private static <T> String convertListToString(Collection<T> list) {
        String stringOfList = "";
        if (list != null) {
            StringBuffer sb = new StringBuffer();
            boolean firstTime = true;
            for (T item : list) {
                if (firstTime) {
                    sb.append(item);/*  ww w  . ja  v  a 2s  . c  o m*/
                    firstTime = false;
                } else {
                    sb.append("||" + item);
                }
            }
            stringOfList = sb.toString();
        }
        return stringOfList;
    }
}

Related

  1. commaSeparatedString(List list, boolean quoteStrings)
  2. convertCollectionToCommaDelimitedString(Collection collection)
  3. convertCollectionToString( Collection strings, String separator)
  4. convertCollectionToString(Collection coll, String delimiter)
  5. convertEnumsToString(Collection> enums)
  6. convertString(Collection strings)
  7. convertStringCollectionToString(Collection collectionString, String delemeter)
  8. convertStringCollectionToString(Collection value, String separator)
  9. convertToString(Collection ss)