Java List Join joinList(List list, String separator)

Here you can find the source of joinList(List list, String separator)

Description

join List

License

Apache License

Declaration

public static String joinList(List list, String separator) 

Method Source Code

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

import java.util.*;

public class Main {
    public static String joinList(List list, String separator) {
        StringBuilder result = new StringBuilder();

        for (Object o : list) {
            if (o == null || o.equals(""))
                continue;
            result.append(o.toString()).append(separator);
        }/* ww  w  . jav  a  2 s.c o  m*/

        int i = result.lastIndexOf(separator);
        if (i >= 0) {
            result.delete(i, result.length());
        }

        return result.toString();
    }
}

Related

  1. joinIntegers(List integers, String token)
  2. joinLines(List lines)
  3. joinLinesWithImplicitFinalLine(final List lines)
  4. joinList(final List list)
  5. joinList(final List list, final String sep)
  6. joinList(List list, String separator)
  7. joinList(List items)
  8. joinList(List list, String glue)
  9. joinList(List list, String separator)