Here you can find the source of split(String a, String delim)
public static String[] split(String a, String delim)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static String[] split(String a, String delim) { if ("".equals(a)) return new String[0]; int position = 0; int delimiterIdx = 0; int strLen = a.length(); List<String> resultList = new ArrayList<String>(); int len = delim.length(); while (position <= strLen) { delimiterIdx = a.indexOf(delim, position); if (delimiterIdx > -1) { resultList.add(a.substring(position, delimiterIdx)); } else { resultList.add(a.substring(position, strLen)); break; }// w w w .j a v a 2 s.co m position = delimiterIdx + len; } return (String[]) resultList.toArray(new String[] {}); } }