Here you can find the source of joinString(String separator, String... elements)
public static String joinString(String separator, String... elements)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static String joinString(String separator, String... elements) { return joinString(elements, separator); }//from w ww. ja va 2 s . c o m public static String joinString(Iterable<String> lines, String separator) { StringBuilder sb = new StringBuilder(); for (String line : lines) { if (line != null) { sb.append(line); sb.append(separator); } } if (sb.length() > 0) { sb.deleteCharAt(sb.length() - 1); return sb.toString(); } else { return ""; } } public static String joinString(String[] lines, String separator) { return joinString(Arrays.asList(lines), separator); } }