Here you can find the source of split(String str, char delimiter)
public static List<String> split(String str, char delimiter)
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.List; import android.text.TextUtils; public class Main { public static List<String> split(String str, char delimiter) { if (TextUtils.isEmpty(str)) { return Collections.emptyList(); }//from w w w .j a v a2 s . c o m int substringsCount = 1; for (int i = 0, len = str.length(); i < len; i++) { if (str.charAt(i) == delimiter) { substringsCount++; } } if (substringsCount == 1) { return Collections.singletonList(str); } List<String> split = new ArrayList<String>(substringsCount); int index = str.indexOf(delimiter); int lastIndex = 0; while (index != -1) { split.add(str.substring(lastIndex, index)); lastIndex = index + 1; index = str.indexOf(delimiter, lastIndex); } split.add(str.substring(lastIndex, str.length())); // add the final string after the last delimiter return split; } }