Here you can find the source of parseCSV(String csv)
public static String[] parseCSV(String csv)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static String[] parseCSV(String csv) { List<String> vals = new ArrayList<String>(); boolean quoted = false; StringBuffer val = new StringBuffer(); for (int i = 0; i < csv.length(); i++) { char c = csv.charAt(i); if (c == '\"') { if (quoted) { quoted = false;/* w w w . java2s .c o m*/ } else { quoted = true; } if (i > 0 && csv.charAt(i - 1) == '\"') { val.append(c); } } else if (quoted) { val.append(c); } else if (c == ',') { vals.add(val.toString().trim()); val.setLength(0); } else { val.append(c); } } vals.add(val.toString().trim()); return (String[]) vals.toArray(new String[] {}); } }