Here you can find the source of Split(String line, String sptr)
public static List<String> Split(String line, String sptr)
//package com.java2s; //License from project: BSD License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> Split(String line, String sptr) { List<String> strs = null; if (line == null || sptr == null || line.isEmpty()) return strs; strs = new ArrayList<String>(); int pos = line.indexOf(sptr); if (sptr.isEmpty() || pos == -1) { strs.add(line);//from w w w .ja v a 2 s. c o m return strs; } int begin = 0; while (pos != -1) { strs.add(line.substring(begin, pos)); begin = pos + sptr.length(); pos = line.indexOf(sptr, begin); } strs.add(line.substring(begin)); return strs; } }