Android Utililty Methods String Split

List of utility methods to do String Split

Description

The list of methods to do String Split are organized into topic(s).

Method

String[]split(String original, String separator)
split
Vector nodes = new Vector();
int index = original.indexOf(separator);
while (index >= 0) {
    nodes.addElement(original.substring(0, index));
    original = original.substring(index + separator.length());
    index = original.indexOf(separator);
nodes.addElement(original);
...
String[]split(String original, String separator)
split
Vector nodes = new Vector();
int index = original.indexOf(separator);
while (index >= 0) {
    nodes.addElement(original.substring(0, index));
    original = original.substring(index + separator.length());
    index = original.indexOf(separator);
nodes.addElement(original);
...
String[]split(String s, String sep)
Split the string into an array of strings using one of the separator in 'sep'.
Vector<Integer> tokenIndex = new Vector<Integer>(10);
int len = s.length();
int i;
for (i = 0; i < len; i++) {
    if (sep.indexOf(s.charAt(i)) != -1) {
        tokenIndex.addElement(new Integer(i));
int size = tokenIndex.size();
String[] elements = new String[size + 1];
if (size == 0) {
    elements[0] = s;
} else {
    int start = 0;
    int end = (tokenIndex.elementAt(0)).intValue();
    elements[0] = s.substring(start, end);
    for (i = 1; i < size; i++) {
        start = (tokenIndex.elementAt(i - 1)).intValue() + 1;
        end = (tokenIndex.elementAt(i)).intValue();
        elements[i] = s.substring(start, end);
    start = (tokenIndex.elementAt(i - 1)).intValue() + 1;
    elements[i] = (start < s.length()) ? s.substring(start) : "";
return elements;
String[]split(String source, String separator)
split
String[] returnVal = null;
int cnt = 1;
int index = source.indexOf(separator);
int index0 = 0;
while (index >= 0) {
    cnt++;
    index = source.indexOf(separator, index + 1);
returnVal = new String[cnt];
cnt = 0;
index = source.indexOf(separator);
while (index >= 0) {
    returnVal[cnt] = source.substring(index0, index);
    index0 = index + 1;
    index = source.indexOf(separator, index + 1);
    cnt++;
returnVal[cnt] = source.substring(index0);
return returnVal;
Listsplit(String str, String delim)
split
String[] words = str.split(delim);
return Arrays.asList(words);
String[]split(String str, String delimiter)
same as the String.split(), except it doesn't use regexes, so it's faster.
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()]);
String[]split(String str, String delims)
split
return split(str, delims, false);
String[]split(String str, String separator)
split
if (str == null) {
    return null;
String[] result;
int i = 0; 
StringTokenizer st = new StringTokenizer(str, separator);
result = new String[st.countTokens()];
while (st.hasMoreTokens()) {
...
String[]split(final String str, final String delim)
split
if (isEmpty(str)) {
    return EMPTY_STRINGS;
List list = new ArrayList();
StringTokenizer st = new StringTokenizer(str, delim);
while (st.hasMoreElements()) {
    list.add(st.nextElement());
return (String[]) list.toArray(new String[list.size()]);
String[]splitDirString(String dirSection)
split Dir String
if (dirSection == null || "".equals(dirSection.trim()))
    return null;
dirSection = dirSection.trim();
if ('/' == (dirSection.charAt(0))) {
    dirSection = dirSection.substring(1);
if (dirSection != null && !"".equals(dirSection)) {
    if ('/' == (dirSection.charAt(dirSection.length() - 1))) {
...