Here you can find the source of split(final String str, final char separatorChar)
public static 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 final String[] EMPTY_STRING_ARRAY = new String[0]; public static String[] split(final String str, final char separatorChar) { if (str == null) { return null; }//ww w . j a va2 s . c om final int len = str.length(); if (len == 0) { return EMPTY_STRING_ARRAY; } final List<String> list = new ArrayList<>(); int i = 0, 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; } else { match = true; i++; } } if (match) { list.add(str.substring(start, i)); } else if (list.isEmpty()) { return EMPTY_STRING_ARRAY; } return list.toArray(new String[list.size()]); } public static boolean isEmpty(String str) { return str == null || str.isEmpty(); } }