Here you can find the source of split(String str, char separator)
public static String[] split(String str, char separator)
//package com.java2s; //License from project: LGPL import java.util.List; import java.util.ArrayList; public class Main { public static String[] split(String str, char separator) { if (str == null) return null; if (str.length() == 0) return new String[0]; List splitList = new ArrayList(); int startPos = 0; int endPos = str.indexOf(separator); while (endPos != -1) { splitList.add(str.substring(startPos, endPos).trim()); startPos = endPos + 1;//from w ww.ja va 2s .c om endPos = str.indexOf(separator, startPos); } splitList.add(str.substring(startPos).trim()); return (String[]) splitList.toArray(new String[splitList.size()]); } }