Here you can find the source of split(char elem, String orig)
public static final String[] split(char elem, String orig)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**//from ww w . j a v a2 s. c o m * split on the given character, with the resulting tokens not including that character * @return non-null */ public static final String[] split(char elem, String orig) { return split("" + elem, orig); } /** * split on all of the characters in splitElements, with the resulting tokens not including that character * @return non-null */ public static final String[] split(String splitElements, String orig) { return split(splitElements, orig, true); } /** * @return non-null */ public static final String[] split(String splitElements, String orig, boolean includeZeroSizedElem) { List vals = new ArrayList(); int off = 0; int start = 0; char str[] = orig.toCharArray(); while (off < str.length) { if (splitElements.indexOf(str[off]) != -1) { String val = null; if (off - start > 0) { val = new String(str, start, off - start); } else { val = ""; } if ((val.trim().length() > 0) || (includeZeroSizedElem)) vals.add(val); start = off + 1; } off++; } String val; if (off - start > 0) val = new String(str, start, off - start); else val = ""; if ((val.trim().length() > 0) || (includeZeroSizedElem)) vals.add(val); String rv[] = new String[vals.size()]; for (int i = 0; i < rv.length; i++) rv[i] = (String) vals.get(i); return rv; } }