Here you can find the source of joinAndQuote(char joinChar, char quoteChar, List
public static String joinAndQuote(char joinChar, char quoteChar, List<String> strings)
//package com.java2s; //License from project: Open Source License import java.util.List; public class Main { public static String joinAndQuote(char joinChar, char quoteChar, List<String> strings) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.size(); ++i) { sb.append(quoteChar);/* w w w.j av a 2s. c o m*/ sb.append(strings.get(i)); if (i + 1 < strings.size()) { sb.append(joinChar); } sb.append(quoteChar); } return sb.toString(); } public static String joinAndQuote(char joinChar, char quoteChar, String[] strings) { if (strings == null) { return ""; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < strings.length; ++i) { sb.append(quoteChar); sb.append(strings[i]); if (i + 1 < strings.length) { sb.append(joinChar); } sb.append(quoteChar); } return sb.toString(); } }