Java Comma Separated List commalist(List l)

Here you can find the source of commalist(List l)

Description

commalist

License

Open Source License

Declaration

public static String commalist(List l) 

Method Source Code

//package com.java2s;

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

public class Main {
    public static final String COMMA = ",".intern();

    public static String commalist(List l) {
        StringBuffer buf = new StringBuffer();
        Iterator i = l.iterator();
        while (i.hasNext()) {
            buf.append(i.next().toString());
            if (i.hasNext())
                buf.append(',');
        }/* ww w. j  av a 2  s  . c  o m*/
        return buf.toString();
    }

    public static String commalist(Object o1, Object o2) {
        return o1 + COMMA + o2;
    }

    public static String commalist(Object o1, Object o2, Object o3) {
        return o1 + COMMA + o2 + COMMA + o3;
    }

    public static String commalist(Object o1, Object o2, Object o3, Object o4) {
        return o1 + COMMA + o2 + COMMA + o3 + COMMA + o4;
    }
}

Related

  1. commaDelimitedListToStringArray(String str)
  2. commaDelimitedListToStringArray(String str)
  3. commaDelimitedStringToList(String str)
  4. commaDelimitedToList(String commaDelimited)
  5. commalist(List l)
  6. commandToString(List args)
  7. commaSeparate(List a_list)
  8. commaSeparatedClassNames(final List objects)
  9. commaSeparatedList(Collection c)

  10. HOME | Copyright © www.java2s.com 2016