Here you can find the source of join(List list, String flag)
@SuppressWarnings("unchecked") public static String join(List list, String flag)
//package com.java2s; import java.util.List; public class Main { @SuppressWarnings("unchecked") public static String join(List list, String flag) { String res = ""; if (list != null) { StringBuilder sb = new StringBuilder(); int len = list.size(); for (int i = 0; i < len; i++) { sb.append(flag);// www. j a va2 s.co m sb.append(list.get(i)); } res = sb.replace(0, 1, "").toString(); } return res; } public static String replace(String str, String flag, String[] replaceAry) { if (str != null && replaceAry != null) { for (int i = 0; i < replaceAry.length; i++) { str = str.replaceFirst("\\" + flag, replaceAry[i]); } } return str; } public static String replace(String str) { return str.replaceAll("\n|\b|\r|\t| | | ", "").replace("> <", "><"); } }