Here you can find the source of splitString(String src, String target)
public static String[] splitString(String src, String target)
//package com.java2s; // License & terms of use: http://www.unicode.org/copyright.html#License import java.util.ArrayList; public class Main { public static String[] splitString(String src, String target) { return src.split("\\Q" + target + "\\E"); }/*from ww w . j a va2s .co m*/ /** * Split a string into pieces based on the given divider character * @param s the string to split * @param divider the character on which to split. Occurrences of * this character are not included in the output * @param output an array to receive the substrings between * instances of divider. It must be large enough on entry to * accomodate all output. Adjacent instances of the divider * character will place empty strings into output. Before * returning, output is padded out with empty strings. */ public static void split(String s, char divider, String[] output) { int last = 0; int current = 0; int i; for (i = 0; i < s.length(); ++i) { if (s.charAt(i) == divider) { output[current++] = s.substring(last, i); last = i + 1; } } output[current++] = s.substring(last, i); while (current < output.length) { output[current++] = ""; } } /** * Split a string into pieces based on the given divider character * @param s the string to split * @param divider the character on which to split. Occurrences of * this character are not included in the output * @return output an array to receive the substrings between * instances of divider. Adjacent instances of the divider * character will place empty strings into output. */ public static String[] split(String s, char divider) { int last = 0; int i; ArrayList<String> output = new ArrayList<String>(); for (i = 0; i < s.length(); ++i) { if (s.charAt(i) == divider) { output.add(s.substring(last, i)); last = i + 1; } } output.add(s.substring(last, i)); return output.toArray(new String[output.size()]); } }