Java List Join joinTextWithCommas(List list)

Here you can find the source of joinTextWithCommas(List list)

Description

join Text With Commas

License

Apache License

Declaration

public static String joinTextWithCommas(List<String> list) 

Method Source Code


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

import java.util.Iterator;
import java.util.List;

public class Main {
    public static String joinTextWithCommas(List<String> list) {
        StringBuffer buf = new StringBuffer();
        if (list.size() > 0) {
            Iterator<String> iterator = list.iterator();
            for (int i = 0; iterator.hasNext(); i++) {
                String field = iterator.next();
                buf.append(field);/*ww w.java2s  .  c om*/
                if (i < list.size())
                    buf.append(", ");
            }
        }
        return buf.toString();
    }
}

Related

  1. joinStrings(List list, String delim)
  2. joinStrings(List strings, String separator)
  3. joinStrings(List strings, String separator)
  4. joinStrings(String delim, List strings)
  5. joinStrings(String joiner, List objects)
  6. joinThreads(List threads)
  7. joinTokens(final List tokens)
  8. joinToString(List list)
  9. JoinToString(List list, String delimiter)