Here you can find the source of join2(String connector, String... strs)
public static String join2(String connector, String... strs)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { /** EMPTY [String] */ public static final String EMPTY = ""; public static String join2(String connector, String... strs) { StringBuffer sBuffer = new StringBuffer(); for (Object object : strs) { sBuffer.append(object).append(connector); }/*from w w w .j a v a2s.c o m*/ if (sBuffer.length() > 0) { sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length()); } return sBuffer.toString(); } public static String join2(String connector, List<Object> objects) { StringBuffer sBuffer = new StringBuffer(); for (Object object : objects) { sBuffer.append(object).append(connector); } if (sBuffer.length() > 0) { sBuffer.delete(sBuffer.length() - connector.length(), sBuffer.length()); } return sBuffer.toString(); } public static String toString(Object object) { return object == null ? EMPTY : object.toString(); } }