Java List to String listToStr(Collection c, String delim)

Here you can find the source of listToStr(Collection c, String delim)

Description

list To Str

License

Apache License

Declaration

public static <TypeName> String listToStr(Collection<TypeName> c, String delim) 

Method Source Code

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

import java.util.Collection;

import java.util.Iterator;

public class Main {
    public static <TypeName> String listToStr(Collection<TypeName> c, String delim) {
        StringBuilder sb = new StringBuilder();
        int a = 0;
        for (Iterator<TypeName> i = c.iterator(); i.hasNext();) {
            TypeName s = i.next();//from  w w  w .  java  2 s. c  o  m
            sb.append(s);
            if (++a >= c.size())
                break;
            sb.append(delim);
        }
        return sb.toString();
    }
}

Related

  1. convertListToString(List strings)
  2. convertListToString(List strList)
  3. convertListToString(List valueList)
  4. convertListToStringWithSeparator( List myList, String separator)
  5. listToStr(Collection a, char sep)
  6. listToStr(List lst)
  7. listToStr(List list)
  8. listToStr(List stringList)
  9. listToStrArray(List list)