Here you can find the source of split(String str, String token)
Parameter | Description |
---|---|
str | a standard str |
token | a token ( not pattern !!! ) |
public static String[] split(String str, String token)
//package com.java2s; //License from project: LGPL import java.util.ArrayList; public class Main { /**//from www . j ava2 s .c o m * split a String, if there are no character between two token this method place * a empty String ( != String.split ) * * @param str * a standard str * @param token * a token ( not pattern !!! ) * @return a array of String without the separator */ public static String[] split(String str, String token) { int i = str.indexOf(token); int start = 0; ArrayList<String> arrayList = new ArrayList<String>(); while (i >= 0) { arrayList.add(str.substring(start, i)); start = i + 1; i = str.indexOf(token, start); } arrayList.add(str.substring(start, str.length())); String[] res = new String[arrayList.size()]; arrayList.toArray(res); return res; } }