Here you can find the source of split(String cmd)
public static String[] split(String cmd)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { private static final String NUMBER_PREFIX = "<n:"; private static final String NUMBER_SUFFIX = ">"; public static String[] split(String cmd) { List<String> splitList = new ArrayList<String>(); split(splitList, cmd);/* w ww. ja va2 s .c o m*/ return splitList.toArray(new String[splitList.size()]); } public static void split(List<String> splitList, String cmd) { int number_start = cmd.indexOf(NUMBER_PREFIX); if (number_start != -1) { int number_end = cmd.indexOf(NUMBER_SUFFIX, number_start); if (number_end != -1) { if (number_start > 0) splitList.add(cmd.substring(0, number_start)); number_end += NUMBER_SUFFIX.length(); splitList.add(cmd.substring(number_start, number_end)); if (number_end < cmd.length()) { String remain = cmd.substring(number_end); split(splitList, remain); } } else { splitList.add(cmd); } } else { splitList.add(cmd); } } }