Java List Join join(List p_sStrList, String p_sDelimiter)

Here you can find the source of join(List p_sStrList, String p_sDelimiter)

Description

The method concatenates a list of strings with the given delimiter

License

Apache License

Parameter

Parameter Description
p_sStrList string list
p_sDelimiter delimiter

Return

concatenated strings

Declaration

public static String join(List<String> p_sStrList, String p_sDelimiter) 

Method Source Code


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

import java.util.List;

public class Main {
    /**//from  w  w w  . j  a v a  2  s  .c  om
     * The method concatenates a list of strings with the given delimiter
     * 
     * @param p_sStrList string list
     * @param p_sDelimiter delimiter
     * @return concatenated strings
     */
    public static String join(List<String> p_sStrList, String p_sDelimiter) {
        StringBuilder sb = new StringBuilder();
        for (String sCurrStr : p_sStrList) {
            if (sb.length() > 0)
                sb.append(p_sDelimiter);
            sb.append(sCurrStr);
        }
        return sb.toString();
    }
}

Related

  1. join(List list1, List list2)
  2. join(List list1, List list2)
  3. join(List lst, int start, int end)
  4. join(List lst, String separator)
  5. join(List members, boolean quote)
  6. join(List parts, String separator)
  7. join(List paths)
  8. join(List s, String delim)
  9. join(List s, String sep)