Here you can find the source of split(String string, String delimiter)
public static String[] split(String string, String delimiter)
//package com.java2s; //License from project: GNU General Public License import java.util.ArrayList; import java.util.List; public class Main { public static String[] split(String string, String delimiter) { if (string == null || string.equals("")) return new String[0]; List<String> list = new ArrayList<String>(); int offset = 0; for (;;) { int nextOffset = string.indexOf(delimiter, offset); if (nextOffset < 0) { list.add(string.substring(offset)); break; }/*from w w w . j av a 2 s . com*/ list.add(string.substring(offset, nextOffset)); offset = nextOffset + 1; } String[] result = new String[list.size()]; for (int i = 0; i < result.length; i++) result[i] = list.get(i); return result; } }