Java String Split by Delimiter splitToken(String str, String delimiter)

Here you can find the source of splitToken(String str, String delimiter)

Description

split Token

License

Apache License

Declaration

public static List<String> splitToken(String str, String delimiter) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static List<String> splitToken(String str, String delimiter) {
        List<String> result = new ArrayList<String>();
        int delimiterIndex = str.indexOf(delimiter);
        if (delimiterIndex < 0) {
            result.add(str);//from   w w  w .  j a va 2 s.c  o m
        } else {
            result.add(str.substring(0, delimiterIndex));
            result.addAll(splitToken(
                    str.substring(delimiterIndex + delimiter.length()),
                    delimiter));
        }
        return result;
    }
}

Related

  1. splitString(String toSplit, String delimiter)
  2. splitStringList(String strList, String delimit)
  3. splitStringUsingDelimiter(String name, String delimiter)
  4. splitText(String text, String delimiter)
  5. splitToArray(String stringToSplit, String delimitter, boolean trim)
  6. splitToList(final String string, final String delim, final int limit)
  7. splitToList(String a_text, String a_delimiter)
  8. splitToList(String s, String delimRegEx)
  9. splitToList(String str, char delimiter)