Java List Join joinStrings(String joiner, List objects)

Here you can find the source of joinStrings(String joiner, List objects)

Description

join Strings

License

Open Source License

Declaration

public static <T> String joinStrings(String joiner, List<T> objects) 

Method Source Code

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

import java.util.List;

public class Main {
    public static <T> String joinStrings(String joiner, List<T> objects,
            boolean wantBlanks) {
        StringBuilder result = new StringBuilder();
        boolean first = true;
        for (T object : objects) {
            String piece = object.toString();
            if (piece.equals("") && !wantBlanks) {
                continue;
            }/*from   w  ww  .j a v a2 s .c o  m*/
            if (first) {
                first = false;
            } else {
                result.append(joiner);
            }
            result.append(piece);
        }
        return result.toString();
    }

    public static <T> String joinStrings(String joiner, List<T> objects) {
        return joinStrings(joiner, objects, false);
    }
}

Related

  1. joinStrings(List aList, String aString)
  2. joinStrings(List list, String delim)
  3. joinStrings(List strings, String separator)
  4. joinStrings(List strings, String separator)
  5. joinStrings(String delim, List strings)
  6. joinTextWithCommas(List list)
  7. joinThreads(List threads)
  8. joinTokens(final List tokens)
  9. joinToString(List list)