Here you can find the source of sanitizeListForCsv(List
Sanitizes the list of strings for comma-separated values (CSV) file output.<br> We follow the definition described by RFC 4180:<br> http://tools.ietf.org/html/rfc4180
public static List<String> sanitizeListForCsv(List<String> strList)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class Main { /**//from w w w. j a v a2 s .c om * Sanitizes the list of strings for comma-separated values (CSV) file output.<br> * We follow the definition described by RFC 4180:<br> * {@link http://tools.ietf.org/html/rfc4180} */ public static List<String> sanitizeListForCsv(List<String> strList) { List<String> sanitizedStrList = new ArrayList<String>(); Iterator<String> itr = strList.iterator(); while (itr.hasNext()) { sanitizedStrList.add(sanitizeForCsv(itr.next())); } return sanitizedStrList; } /** * Sanitizes the string for comma-separated values (CSV) file output.<br> * We follow the definition described by RFC 4180:<br> * {@link http://tools.ietf.org/html/rfc4180} */ public static String sanitizeForCsv(String str) { return "\"" + str.replace("\"", "\"\"") + "\""; } }