Here you can find the source of SplitAt(String s, String delimiter)
private static String[] SplitAt(String s, String delimiter)
//package com.java2s; import java.util.ArrayList; public class Main { private static String[] SplitAt(String s, String delimiter) { if (delimiter == null || delimiter.length() == 0) throw new IllegalArgumentException(); if (s == null || s.length() == 0) return new String[] { "" }; int index = 0; boolean first = true; ArrayList<String> strings = null; int delimLength = delimiter.length(); while (true) { int index2 = s.indexOf(delimiter, index); if (index2 < 0) { if (first) return new String[] { s }; strings.add(s.substring(index)); break; } else { if (first) { strings = new ArrayList<String>(); first = false;/* ww w. j av a 2s.c om*/ } String newstr = s.substring(index, index2); strings.add(newstr); index = index2 + delimLength; } } return strings.toArray(new String[] {}); } }