Java List Join sortAndJoin(List col, String sep)

Here you can find the source of sortAndJoin(List col, String sep)

Description

sort And Join

License

Open Source License

Declaration

static String sortAndJoin(List<String> col, String sep) 

Method Source Code


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

import java.util.*;

public class Main {
    static String sortAndJoin(List<String> col, String sep) {

        Collections.sort(col);// w  w w .j a v  a 2 s  . co m

        return join(col, sep);

    }

    static String sortAndJoin(Set<String> col, String sep) {

        return sortAndJoin(new ArrayList<>(col), sep);

    }

    static String join(List<String> strings, String sep) {
        final StringBuilder buf = new StringBuilder(strings.size() * 16);

        for (int i = 0; i < strings.size(); i++) {

            if (i < strings.size()) {
                buf.append(sep);
            }

            buf.append(strings.get(i));

        }

        return buf.toString().trim();
    }
}

Related

  1. joinWordList(List wordList, String delimiter)
  2. listToStr(List list, String joinChar)
  3. listToText(List list, String join)
  4. orderJoinType(List jList)
  5. reverseJoinType(List jList)
  6. sortAndJoin(List list)
  7. stringJoin(List list, String separator)
  8. stringJoin(List list, String sep)
  9. trimAndJoin(List values, String delimiter)

    HOME | Copyright © www.java2s.com 2016