Here you can find the source of split(String str, String delimiter)
Parameter | Description |
---|---|
str | - the string to split up |
delimiter | the delimiter |
public static String[] split(String str, String delimiter)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**/* ww w .jav a 2s . com*/ * same as the String.split(), except it doesn't use regexes, so it's faster. * * @param str - the string to split up * @param delimiter the delimiter * @return the split string */ public static String[] split(String str, String delimiter) { List<String> result = new ArrayList<String>(); int lastIndex = 0; int index = str.indexOf(delimiter); while (index != -1) { result.add(str.substring(lastIndex, index)); lastIndex = index + delimiter.length(); index = str.indexOf(delimiter, index + delimiter.length()); } result.add(str.substring(lastIndex, str.length())); return result.toArray(new String[result.size()]); } }