Java List Join join(List values, String separator)

Here you can find the source of join(List values, String separator)

Description

join

License

Apache License

Declaration

public static <T> String join(List<T> values, String separator) 

Method Source Code

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

import java.util.List;

public class Main {
    public static <T> String join(List<T> values, String separator) {
        StringBuilder result = new StringBuilder();
        for (Object value : values) {
            String v = value.toString().trim();
            if (hasLength(v)) {
                if (result.length() > 0) {
                    result.append(separator);
                }//from   ww  w .ja  v  a2  s .  c  om
                result.append(v);
            }
        }
        return result.toString();
    }

    public static boolean hasLength(String str) {
        return str != null && str.length() > 0;
    }
}

Related

  1. join(List list, String separator)
  2. join(List objects, String separator)
  3. join(List objs, String delim)
  4. join(List target, String splite)
  5. join(List tokens, String delimiter)
  6. join(List... lists)
  7. join(List... ls)
  8. join(List... elements)
  9. join(String _delimiter, List _strings)