Here you can find the source of splitOnChar(String str, char c)
public static String[] splitOnChar(String str, char c)
//package com.java2s; import java.util.ArrayList; public class Main { public static String[] splitOnChar(String str, char c) { ArrayList<String> result = new ArrayList<String>(); int lastOffset = 0; int curOffset; while ((curOffset = str.indexOf(c, lastOffset)) != -1) { result.add(str.substring(lastOffset, curOffset)); lastOffset = curOffset + 1;/*from w w w. j a v a 2 s . c om*/ } result.add(str.substring(lastOffset)); return result.toArray(new String[result.size()]); } }