Here you can find the source of splitCSV(String str)
public static String[] splitCSV(String str)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static String[] splitCSV(String str) { ArrayList<String> split = new ArrayList<String>(); int i = 0; int quotes = 0; int index = str.indexOf(","); int start = 0; int stop = str.length(); while (index != -1) { String temp = str.substring(0, index); //from the start to the comma for (int j = 0; j < temp.length(); j++) { if (temp.charAt(j) == '\"') { quotes++;/* w ww. j a va 2 s . c o m*/ } //if } //for if ((quotes % 2) == 1) { String temp2 = str.substring(0, index + 1); int index2 = temp2.indexOf(","); String temp3 = str.substring(1, 1 + index + index2); split.add(temp3);//adds the string str = str.substring(1 + index + index2); break; } //if else { split.add(temp); } //else str = str.substring(index + 1); start = index; index = str.indexOf(","); } //outer while split.add(str); String[] splitstring = split.toArray(new String[split.size()]); return splitstring; } }