Here you can find the source of split(String str, char sep)
public static String[] split(String str, char sep)
//package com.java2s; /*//from w ww . ja v a 2 s . c om * MoXie (SysTem128@GMail.Com) 2009-3-11 10:06:36 * * Copyright © 2008-2009 Zoeey.Org * Code license: GNU Lesser General Public License Version 3 * http://www.gnu.org/licenses/lgpl-3.0.txt */ import java.util.ArrayList; import java.util.List; public class Main { public static String[] split(String str, char sep) { if (str == null) { return new String[0]; } int length = str.length(); char ch = 0; List<String> strList = new ArrayList<String>(); StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < length; i++) { ch = str.charAt(i); if (ch == sep) { strList.add(strBuilder.toString()); strBuilder = new StringBuilder(); } else { strBuilder.append(ch); } } strList.add(strBuilder.toString()); strBuilder = null; return strList.toArray(new String[strList.size()]); } }