Here you can find the source of split(String str, char cha)
public static List<String> split(String str, char cha)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; import java.util.List; public class Main { public static List<String> split(String str, char cha) { System.out.println(str + ":" + cha); List<String> list = new ArrayList<String>(); StringBuffer sbf = new StringBuffer(str); StringBuffer newSbf = new StringBuffer(""); for (int i = 0; i < sbf.length(); i++) { char c = sbf.charAt(i); if (c == cha) { list.add(newSbf.toString()); newSbf.delete(0, newSbf.length()); } else { newSbf.append(c);/*w w w . j a v a 2 s . c om*/ } if (i == sbf.length() - 1) { list.add(newSbf.toString()); } } return list; } }