Java Collection Concatenate concatStringsWSep(Collection strings, String separator)

Here you can find the source of concatStringsWSep(Collection strings, String separator)

Description

concat Strings W Sep

License

Open Source License

Declaration

public static String concatStringsWSep(Collection<String> strings, String separator) 

Method Source Code


//package com.java2s;
import java.util.Collection;

public class Main {
    public static String concatStringsWSep(Collection<String> strings, String separator) {
        StringBuilder sb = new StringBuilder();
        String sep = "";
        for (String s : strings) {
            sb.append(sep).append(s);//from w w w . java  2 s  .co  m
            sep = separator;
        }
        return sb.toString();
    }
}

Related

  1. concatInt(Collection collection)
  2. concatNames(Collection cNames, String split)
  3. concatNumber(Collection keys)
  4. concatStrings(Collection strings)
  5. concatStrings(Collection values, String separator)
  6. concatTokens(Collection tokens)
  7. concatValues(Collection values)