Here you can find the source of split(String line, String separator)
static ArrayList<String> split(String line, String separator)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; public class Main { static ArrayList<String> split(String line, String separator) { ArrayList<String> items = new ArrayList<String>(); int start, end; int sep_size = separator.length(); start = 0;// w w w . j a v a 2 s. c o m //See: http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions) end = line.indexOf(separator); while (end != -1) //See: http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions) >> returns this if not found { items.add(line.substring(start, end)); start = end + sep_size; end = line.indexOf(separator, start); } items.add(line.substring(start, line.length())); return items; } }