Here you can find the source of split(String str, String delimiter)
public static String[] split(String str, String delimiter)
//package com.java2s; import java.util.ArrayList; public class Main { public static String[] split(String str, String delimiter) { ArrayList list = new ArrayList(); int idx = 0; while (true) { idx = str.indexOf(delimiter); if (idx == -1) { list.add(str);//from w w w .j a v a2 s . c o m break; } list.add(str.substring(0, idx)); str = str.substring(idx + delimiter.length()); } return (String[]) list.toArray(new String[list.size()]); } }