Here you can find the source of split(String line, String regex)
public static String[] split(String line, String regex)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { public static String[] split(String line, String regex) { List<String> strings = new ArrayList<String>(); String part = ""; for (int i = 0; i < line.length() - (regex.length() - 1); i++) { if (line.substring(i, i + regex.length()).equalsIgnoreCase( regex)) {//from w w w .j a va2s. c om strings.add(part); part = ""; i = i + regex.length() - 1; } else { part += line.charAt(i); } } strings.add(part); String[] parts = new String[strings.size()]; for (int i = 0; i < strings.size(); i++) { parts[i] = strings.get(i); } return parts; } }