Java List Join joinList(String separater, List list)

Here you can find the source of joinList(String separater, List list)

Description

Join a list of string together

License

Open Source License

Parameter

Parameter Description
separater a parameter
list a parameter

Return

the string

Declaration

public static String joinList(String separater, List<String> list) 

Method Source Code

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

import java.util.List;

public class Main {
    /**/*from  ww  w .  j  ava 2 s .c o m*/
     * Join a list of string together
     * 
     * @param separater
     * @param list
     * @return the string
     */
    public static String joinList(String separater, List<String> list) {
        String result = "";

        for (int i = 0; i < list.size(); i++) {
            result = result + list.get(i) + separater;
        }

        if (!result.equals("")) {
            result = result.substring(0, result.length() - separater.length());
        }

        return result;
    }
}

Related

  1. joinList(List list, String separator)
  2. joinList(List items)
  3. joinList(List list, String glue)
  4. joinList(List list, String separator)
  5. joinList(List parts, String sep)
  6. joinLists( final List> lists)
  7. joinLists(List A, List B, double epsilon)
  8. joinLists(List... list)
  9. joinListToString(List lsStr, String sSeparator)