RDBExport { protected static List<String> parseDel(String line) { ArrayList<String> result = new ArrayList<String>(); boolean inQuoted = false; char quotechar = '"'; char fielddelim = ','; StringBuilder value = new StringBuilder(); for (int i = 0; i < line.length(); i++) { char c = line.charAt(i); if (!inQuoted) { if (c == fielddelim) { result.add(value.toString()); value = new StringBuilder(); } else { if (value.length() == 0 && c == quotechar) { inQuoted = true; } else { value.append(c); } } } else { if (c == quotechar) { if (i + 1 != line.length() && line.charAt(i + 1) == quotechar) { value.append(c); i += 1; } else { inQuoted = false; } } else { value.append(c); } } } result.add(value.toString()); return result; }  static void main(String[] args);  }
@Test public void testparseDel() { String[] empty = new String[0]; String[] result; result = RDBExport.parseDel("1,2,3").toArray(empty); assertArrayEquals(new String[] { "1", "2", "3" }, result); result = RDBExport.parseDel("\"a\",\"b,c\",\"d\"\"e\"").toArray(empty); assertArrayEquals(new String[] { "a", "b,c", "d\"e" }, result); }