Java List to String listToString(List params, String sepator)

Here you can find the source of listToString(List params, String sepator)

Description

list To String

License

Apache License

Declaration

public static String listToString(List<String> params, String sepator) 

Method Source Code

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

import java.util.List;

public class Main {
    public static String listToString(List<String> params, String sepator) {
        if (params.size() > 0) {
            StringBuffer buffer = new StringBuffer();
            for (String string : params) {
                buffer.append(string + sepator);
            }//from w w  w. j  a va2  s. c o m
            String result = buffer.toString();
            return result.substring(0, result.length() - 1);
        } else {
            return "";
        }
    }

    public static String listToString(List<String> strings) {
        StringBuffer buffer = new StringBuffer();
        if (strings != null) {
            for (String string : strings) {
                buffer.append("\"" + string + "\",");
            }
            return buffer.toString().substring(0, buffer.toString().length() - 1);
        }
        return buffer.append(" ").toString();
    }

    public static String subString(String src, int length) {
        if (src == null) {
            return null;
        }
        int i = src.length();
        if (i > length) {
            return src.substring(0, length);
        }
        return src;
    }
}

Related

  1. listToString(List list, String expr)
  2. listToString(List list, String separator)
  3. listToString(List list, String separator)
  4. listToString(List list, String separator)
  5. listToString(List list, String split)
  6. listToString(List pListToConvert)
  7. listToString(List queryList, String delimitedString)
  8. listToString(List s, String separator)
  9. listToString(List segs, String splitter)