Here you can find the source of splitWithoutEscaped(String str, char separatorChar)
public static String[] splitWithoutEscaped(String str, char separatorChar)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static String[] splitWithoutEscaped(String str, char separatorChar) { return splitWithoutEscaped(str, separatorChar, false); }//from w ww. j a va 2 s. c om /** * does not take into account escaped separators */ public static String[] splitWithoutEscaped(String str, char separatorChar, boolean retainEmpty) { int len = str.length(); if (len == 0) { return new String[0]; } List<String> list = new ArrayList<String>(); int i = 0; int start = 0; boolean match = false; while (i < len) { if (str.charAt(i) == '\\') { match = true; i += 2; } else if (str.charAt(i) == separatorChar) { if (retainEmpty || match) { list.add(str.substring(start, i)); match = false; } start = ++i; } else { match = true; i++; } } if (retainEmpty || match) { list.add(str.substring(start, i)); } return list.toArray(new String[list.size()]); } }