Here you can find the source of parse(String input, char delim, char esc)
public static List<String> parse(String input, char delim, char esc)
//package com.java2s; //License from project: Open Source License import java.util.List; import java.util.ArrayList; public class Main { public static List<String> parse(String input, char delim, char esc) { assert delim != esc : "Delimiter is the same as escaping character: " + delim; List<String> ret = new ArrayList<String>(); StringBuilder cur = new StringBuilder(); boolean escflag = false; for (int i = 0; i < input.length(); i++) { char c = input.charAt(i); if (c == esc) { if (escflag) { cur.append(c);//from w w w. ja v a2 s .c om escflag = false; } else { escflag = true; } } else if (c == delim) { if (escflag) { cur.append(c); } else { ret.add(cur.toString()); cur = new StringBuilder(); } escflag = false; } else { cur.append(c); escflag = false; } } if (cur.length() > 0) { ret.add(cur.toString()); } return ret; } }