Here you can find the source of split(CharSequence seq, char separator)
public static List<String> split(CharSequence seq, char separator)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { private static final char ESCAPE_CHAR = '\\'; public static List<String> split(CharSequence seq, char separator) { List<String> strs = new ArrayList<>(); StringBuilder buffer = new StringBuilder(); int index = 0; while (index < seq.length()) { char ch = seq.charAt(index++); if (ch == ESCAPE_CHAR) { if (index < seq.length()) buffer.append(seq.charAt(index++)); } else if (ch == separator) { strs.add(buffer.toString()); buffer.setLength(0);/*from w w w.j ava 2s .com*/ } else buffer.append(ch); } strs.add(buffer.toString()); return strs; } }