Here you can find the source of split(String str, char separatorChar)
public static String[] split(String str, char separatorChar)
//package com.java2s; import java.util.*; public class Main { public static final String[] EMPTY_STRINGS = {}; public static String[] split(String str, char separatorChar) { if (str == null) { return null; }//ww w .j a v a 2 s .c o m int length = str.length(); if (length == 0) { return EMPTY_STRINGS; } List<String> list = new ArrayList(); int i = 0; int start = 0; boolean match = false; while (i < length) { 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.toArray(new String[list.size()]); } }