public static String[] splitCSVWithQuoteEscape(String line) {

		SortedSet<Integer> commaIndicies = new TreeSet<Integer>();
		Set<Integer> quoteIndicies = new HashSet<Integer>();
		Map<Integer, Integer> priorQuotes = new HashMap<Integer, Integer>();

		char[] array = line.toCharArray();
		for (int i = 0; i < array.length; i++) {
			switch (array[i]) {
			case ',':
				commaIndicies.add(i);
				break;
			case '"':
			case '\'':
				quoteIndicies.add(i);
				break;
			}
			priorQuotes.put(i, quoteIndicies.size());
		}

		Iterator<Integer> it = commaIndicies.iterator();
		while (it.hasNext()) {
			Integer i = it.next();
			if (isOdd(priorQuotes.get(i))) {
				it.remove();
			}
		}

		Integer[] commas = commaIndicies.toArray(new Integer[commaIndicies.size()]);

		List<String> list = new LinkedList<String>();

		if (commas.length > 0) {
			list.add(line.substring(0, commas[0]));
		} else {
			list.add(line);
		}

		for (int i = 0; i < commas.length - 1; i++) {
			list.add(line.substring(commas[i] + 1, commas[i + 1]));
		}

		if (commas.length > 0) {
			list.add(line.substring(commas[commas.length - 1] + 1));
		}

		return list.toArray(new String[list.size()]);
	}