Java List to String listToString(List list, String split)

Here you can find the source of listToString(List list, String split)

Description

list To String

License

Open Source License

Declaration

public static String listToString(List<String> list, String split) 

Method Source Code


//package com.java2s;

import java.util.Collection;

import java.util.List;

public class Main {

    public static String listToString(List<String> list) {
        return listToString(list, ",");
    }//from   w  w  w. j  av a2  s.c  om

    public static String listToString(List<String> list, String split) {
        StringBuilder sb = new StringBuilder();
        if (!isEmpty(list)) {
            for (int i = 0; i < list.size(); i++) {
                if (i < list.size() - 1) {
                    sb.append(list.get(i) + split);
                } else {
                    sb.append(list.get(i));
                }
            }
        }
        return sb.toString();
    }

    public static <T> boolean isEmpty(Collection<T> c) {
        if (c == null || c.isEmpty()) {
            return true;
        } else {
            return false;
        }
    }
}

Related

  1. listToString(List list, String delimiter)
  2. listToString(List list, String expr)
  3. listToString(List list, String separator)
  4. listToString(List list, String separator)
  5. listToString(List list, String separator)
  6. listToString(List params, String sepator)
  7. listToString(List pListToConvert)
  8. listToString(List queryList, String delimitedString)
  9. listToString(List s, String separator)