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

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

Description

list To String

License

Apache License

Declaration

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

Method Source Code


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

import java.util.List;

public class Main {
    public static String listToString(List<String> list, String separator) {
        StringBuilder strBuilder = new StringBuilder();
        boolean notFirst = false;
        for (String element : list) {
            if (element == null || element.trim().length() == 0) {
                continue;
            }//www .j  a v a2s.c  o m
            if (notFirst) {
                strBuilder.append(separator);
            } else {
                notFirst = true;
            }
            strBuilder.append(element);
        }
        return strBuilder.toString();
    }
}

Related

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