Here you can find the source of split(String src, String delimiter)
public static String[] split(String src, String delimiter)
//package com.java2s; import java.util.ArrayList; public class Main { public static String[] split(String src, String delimiter) { if (src == null || delimiter == null || src.trim().equals("") || delimiter.equals("")) { return new String[] { src }; }/* w ww . j ava 2s .c om*/ ArrayList<String> list = new ArrayList<String>(); int lengthOfDelimiter = delimiter.length(); int pos = 0; while (true) { if (pos < src.length()) { int indexOfDelimiter = src.indexOf(delimiter, pos); if (indexOfDelimiter < 0) { list.add(src.substring(pos)); break; } else { list.add(src.substring(pos, indexOfDelimiter)); pos = indexOfDelimiter + lengthOfDelimiter; } } else if (pos == src.length()) { list.add(""); break; } else { break; } } String[] result = new String[list.size()]; list.toArray(result); return result; } public static boolean equals(String one, String another) { if (one == null) { if (another == null) { return true; } else { return false; } } else { if (another == null) { return false; } else { return one.equals(another); } } } public final static String trim(String target) { if (target == null) return null; target = target.trim(); return "".equals(target) ? null : target; } public static String trim(Object src) { if (src == null) { return ""; } String str = src.toString(); return str.trim(); } public static String subString(String parentStr, String startStr, String endStr) { return parentStr.substring(parentStr.indexOf(startStr) + startStr.length(), parentStr.indexOf(endStr)); } }