Java List Join join(char separator, List seqs)

Here you can find the source of join(char separator, List seqs)

Description

join

License

Open Source License

Declaration

public static String join(char separator, List<? extends CharSequence> seqs) 

Method Source Code

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

import java.util.Arrays;
import java.util.List;

public class Main {
    public static String join(char separator, String... strs) {
        return join(Character.toString(separator), false, Arrays.asList(strs));
    }//  w  w w  .java2s  .  c  om

    public static String join(char separator, List<? extends CharSequence> seqs) {
        return join(Character.toString(separator), false, seqs);
    }

    public static String join(CharSequence separator, String... strs) {
        return join(separator, false, Arrays.asList(strs));
    }

    public static String join(CharSequence separator, List<? extends CharSequence> seqs) {
        return join(separator, false, seqs);
    }

    public static String join(char separator, boolean trailingSeparator, String... strs) {
        return join(Character.toString(separator), trailingSeparator, Arrays.asList(strs));
    }

    public static String join(char separator, boolean trailingSeparator, List<? extends CharSequence> seqs) {
        return join(Character.toString(separator), trailingSeparator, seqs);
    }

    public static String join(CharSequence separator, boolean trailingSeparator, String... strs) {
        return join(separator, trailingSeparator, Arrays.asList(strs));
    }

    public static String join(CharSequence separator, boolean trailingSeparator,
            List<? extends CharSequence> seqs) {
        // Calculate length of buffer
        int length = (separator == null) ? 0 : separator.length() * seqs.size();
        for (CharSequence seq : seqs)
            length += seq.length();

        // Concatenate character sequences
        StringBuilder buffer = new StringBuilder(length);
        for (int i = 0; i < seqs.size(); ++i) {
            if ((separator != null) && (i > 0))
                buffer.append(separator);
            buffer.append(seqs.get(i));
        }
        if ((separator != null) && trailingSeparator)
            buffer.append(separator);
        return buffer.toString();
    }
}

Related

  1. concat(List tokens, int start, int end, String joiner)
  2. concatAndJoin(String sep, List data, String prefix, String suffix)
  3. contains(List joinParams, int joinIndex)
  4. getJoinKeyValues(List tuple, List joinKeyIndices)
  5. join(CharSequence delimiter, Iterable list)
  6. join(CharSequence delimiter, List elements)
  7. join(Collection list, String separator)
  8. join(Collection stringList, String seperator)