Java String from List stringList2String(List list, String separator)

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

Description

Return list of strings in a single string separated by a separator string.

License

Open Source License

Parameter

Parameter Description
list The list.
separator The separator.

Return

The new String.

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.List;

public class Main {
    /**/*from w w w.  j  a  v  a2 s . c om*/
     * Return list of strings in a single string separated by a separator
     * string.
     * 
     * @param list
     *            The list.
     * @param separator
     *            The separator.
     * @return The new String.
     */
    public static String stringList2String(List<String> list, String separator) {
        String ret = "";
        for (String s : list) {
            ret += s + separator;
        }
        return ret.substring(0, ret.length() - separator.length());
    }
}

Related

  1. stringfyList(List ls)
  2. stringify(List entries)
  3. stringifyList(List items)
  4. stringList(String prefix, String suffix, String separator, Object... objects)
  5. stringList2String(final String suffix, final List list)
  6. stringListEquals(List left, List right)
  7. stringListString(List list)
  8. stringListToArray(final List list)
  9. stringListToArray(List list)