Here you can find the source of split(final String str, final char separatorChar)
public static List<String> split(final String str, final char separatorChar)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static List<String> split(final String str, final char separatorChar) { return split(str, separatorChar, 10); }/*w ww . jav a 2 s. co m*/ public static List<String> split(final String str, final char separatorChar, int expectParts) { if (str == null) { return null; } final int len = str.length(); if (len == 0) { return new ArrayList<>(); } final List<String> list = new ArrayList<String>(expectParts); int i = 0; int start = 0; boolean match = false; while (i < len) { if (str.charAt(i) == separatorChar) { if (match) { list.add(str.substring(start, i)); match = false; } start = ++i; continue; } match = true; i++; } if (match) { list.add(str.substring(start, i)); } return list; } }