Here you can find the source of splitHandleQuotes(String s)
private static List<String> splitHandleQuotes(String s)
//package com.java2s; /*// w ww . j av a2s. com * Copyright (C) 2009 Emweb bvba, Leuven, Belgium. * * See the LICENSE file for terms of use. */ import java.util.ArrayList; import java.util.List; public class Main { private static List<String> splitHandleQuotes(String s) { ArrayList<String> results = new ArrayList<String>(); char delimiter = ','; char quoteChar = '"'; char escapeChar = '\\'; StringBuffer current = new StringBuffer(""); boolean inQuotation = false; boolean escaping = false; for (int i = 0; i < s.length(); ++i) { if (escaping) { if (s.charAt(i) == quoteChar) current.append(quoteChar); else { current.append(escapeChar); current.append(quoteChar); } escaping = false; } else { if (s.charAt(i) == quoteChar) { inQuotation = !inQuotation; } else if (s.charAt(i) == escapeChar) { escaping = true; } else if (!inQuotation) if (s.charAt(i) == delimiter) { results.add(new String(current)); current = new StringBuffer(""); } else current.append(s.charAt(i)); else current.append(s.charAt(i)); } } results.add(new String(current)); return results; } }