Here you can find the source of join(String[] tokens, String delimiter)
public static String join(String[] tokens, String delimiter)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static String join(String[] tokens, String delimiter) { if (tokens == null) { return "null"; }/*from www . ja v a2 s .co m*/ if (tokens.length == 0) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(tokens[0]); for (int i = 1; i < tokens.length; i++) sb.append(delimiter).append(tokens[i]); return sb.toString(); } public static String join(String[] tokens, String delimiter, int start, int end) { if (tokens == null) { return "null"; } if (tokens.length == 0) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(tokens[start]); for (int i = start + 1; i < end; i++) sb.append(delimiter).append(tokens[i]); return sb.toString(); } public static String join(String delimiter, Object... tkns) { StringBuilder sb = new StringBuilder(); for (Object t : tkns) { sb.append(t.toString()).append(delimiter); } return sb.toString(); } public static String join(String[] tokens, String delimiter, int[] position) { if (tokens == null) { return "null"; } if (tokens.length == 0) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(tokens[0]); position[0] = 0; for (int i = 1; i < tokens.length; i++) { position[i] = sb.length() + delimiter.length(); sb.append(delimiter).append(tokens[i]); } return sb.toString(); } public static String join(List<String> tokens, String delimiter) { if (tokens == null) { return "null"; } if (tokens.size() == 0) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(tokens.get(0)); for (int i = 1; i < tokens.size(); i++) sb.append(delimiter).append(tokens.get(i)); return sb.toString(); } }