Here you can find the source of split(String self)
public static List split(String self)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static List split(String self) { return split(self, null, true); }/*from www. j a va 2 s . co m*/ public static List split(String self, Long separator) { return split(self, separator, true); } public static List split(String self, Long separator, boolean trimmed) { if (separator == null) return splitws(self); int sep = separator.intValue(); boolean trim = trimmed; List toks = new ArrayList<String>(16); int len = self.length(); int x = 0; for (int i = 0; i < len; ++i) { if (self.charAt(i) != sep) continue; if (x <= i) toks.add(splitStr(self, x, i, trim)); x = i + 1; } if (x <= len) toks.add(splitStr(self, x, len, trim)); return toks; } public static List splitws(String val) { List toks = new ArrayList<String>(16); int len = val.length(); while (len > 0 && val.charAt(len - 1) <= ' ') --len; int x = 0; while (x < len && val.charAt(x) <= ' ') ++x; for (int i = x; i < len; ++i) { if (val.charAt(i) > ' ') continue; toks.add(val.substring(x, i)); x = i + 1; while (x < len && val.charAt(x) <= ' ') ++x; i = x; } if (x <= len) toks.add(val.substring(x, len)); if (toks.size() == 0) toks.add(""); return toks; } private static String splitStr(String val, int s, int e, boolean trim) { if (trim) { while (s < e && val.charAt(s) <= ' ') ++s; while (e > s && val.charAt(e - 1) <= ' ') --e; } return val.substring(s, e); } }