Here you can find the source of split(String cs, char sep)
public static List<String> split(String cs, char sep)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.List; public class Main { /**//from w w w . ja v a 2 s.com * Splits a String around occurences of a character. The result is similar to * {@link String#split(String)}. */ public static List<String> split(String cs, char sep) { List<String> list = new ArrayList<>(4); split(cs, sep, list); return list; } /** * Splits a String around occurences of a character, and put the result in a List. The result is similar * to {@link String#split(String)}. */ public static void split(String str, char sep, List<String> list) { int pos0 = 0; for (int i = 0; i < str.length(); i++) { char ch = str.charAt(i); if (ch == sep) { list.add(str.substring(pos0, i)); pos0 = i + 1; } } if (pos0 < str.length()) { list.add(str.substring(pos0, str.length())); } } }