Java 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

ListsplitTags(String rawTags)
split Tags
rawTags = rawTags.trim();
String[] tags = rawTags.split(",");
List<String> currentTags = new ArrayList<String>();
for (String tag : tags) {
    String effectiveTag = tag.replace(",", "").trim();
    if (!"".equals(effectiveTag)) {
        currentTags.add(effectiveTag);
if ("".equals(rawTags)) {
    return Arrays.asList((String[]) new String[] { "" });
if (rawTags.charAt(rawTags.length() - 1) == ',') {
    currentTags.add("");
return currentTags;
String[]splitTemplateName(String templateName)
Splits template name to get identifier, field name and locale
ArrayList result = new ArrayList();
int k = templateName.lastIndexOf("_");
if (k != -1) {
    String locale = templateName.substring(k + 1);
    templateName = templateName.substring(0, k);
    k = templateName.lastIndexOf("_");
    if (k != -1) {
        String field = templateName.substring(k + 1);
...
List>splitter(List list, final int L)
splitter
List<List<T>> parts = new ArrayList<List<T>>();
final int N = list.size();
for (int i = 0; i < N; i += L) {
    parts.add(list.subList(i, Math.min(N, i + L)));
return parts;
String[]splitTerms(String queryString)
split Terms
final List<String> result = new ArrayList<String>();
final StringBuilder builder = new StringBuilder();
final int len = queryString.length();
for (int i = 0; i < len; ++i) {
    final int cp = queryString.codePointAt(i);
    if (!Character.isLetterOrDigit(cp) && cp != ':' && cp != '+' && cp != '^' && cp != '-') {
        if (builder.length() > 0) {
            result.add(builder.toString());
...
ListsplitText(String text)
Split text into lines.
int startLine = 0;
int i = 0;
int n = text.length();
ArrayList<String> rc = new ArrayList<String>();
while (i < n) {
    switch (text.charAt(i)) {
    case '\n':
        i++;
...
ListsplitToInteger(String str)
split To Integer
String[] chars = str.split("");
List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < chars.length; i++) {
    try {
        list.add(new Integer(chars[i]));
    } catch (NumberFormatException nfe) {
return list;
ListsplitTokens(final String targets)
Simple function to split a string into tokens which are loaded into a list, note order IS important.
if (targets.matches(".*\\s.*")) {
    return Arrays.asList(targets.split("\\s+"));
} else {
    return Arrays.asList(targets);
ListsplitTokens(String text)
split Tokens
return splitTokens(text, ",");
ListsplitToList(final String listString, final String split)
split To List
return splitToList(listString, split, false);
ListsplitToList(String s)
split To List
return Arrays.asList(split(s));