Here you can find the source of toEscapedStringWithDelimiters(Collection objects, String delim)
public static String toEscapedStringWithDelimiters(Collection objects, String delim)
//package com.java2s; //License from project: LGPL import java.util.*; public class Main { public static String toEscapedStringWithDelimiters(Collection objects, String delim) { StringBuffer buffer = new StringBuffer(); int index = 0; for (Object obj : objects) { if (index++ > 0) buffer.append(delim);/*ww w . jav a 2 s.c o m*/ String string = obj.toString(); if (string.startsWith("\"") && string.endsWith("\"")) { if (string.length() <= 2) string = "\" \" "; else string = "\"" + replaceQuotationMarks(string.substring(1, string.length() - 1)) + "\""; } buffer.append(string); } return buffer.toString(); } public static String replaceQuotationMarks(String s) { if (s.contains("\"")) { return s.replaceAll("[\"]", "''"); } return s; } }