Here you can find the source of splitCSV(String inputString)
public static String[] splitCSV(String inputString)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { public static String[] splitCSV(String inputString) { ArrayList<String> stringList = new ArrayList<String>(); String tempString;// w ww .j a v a 2s. c om StringBuilder sb = new StringBuilder(); for (int i = 0; i < inputString.length(); i++) { if (inputString.charAt(i) == '"') { i++; while (i < inputString.length()) { if (inputString.charAt(i) == '"' && inputString.charAt(i + 1) == '"') //when there are two double quotation mark next to each other { sb.append('"'); i = i + 2; } if (inputString.charAt(i) == '"') { break; } else { sb.append(inputString.charAt(i)); i++; } } i++; // skip over the double quotation mark } if (inputString.charAt(i) != ',') { sb.append(inputString.charAt(i)); } // if else { tempString = sb.toString(); stringList.add(tempString); sb.setLength(0); } // else } // for // After reaching the last character of the string, we need to do the // following tempString = sb.toString(); stringList.add(tempString); sb.setLength(0); String[] stockArr = new String[stringList.size()]; stockArr = stringList.toArray(stockArr); return stockArr; } }