Java String Split splitSubstring(String str, String substr)

Here you can find the source of splitSubstring(String str, String substr)

Description

split Substring

License

Apache License

Declaration

public static ArrayList<String> splitSubstring(String str, String substr) 

Method Source Code

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

import java.util.*;

public class Main {
    public static ArrayList<String> splitSubstring(String str, String substr) {
        ArrayList<String> split = new ArrayList<String>();
        int idx_s = 0;
        int idx_e = str.indexOf(substr);
        while (idx_e > -1) {
            String f = str.substring(idx_s, idx_e);
            split.add(f.trim());/*from  w  w w.j a  va  2 s  .co  m*/
            idx_s = idx_e + substr.length();
            idx_e = str.indexOf(substr, idx_s);
        }
        if (idx_s < str.length()) {
            String f = str.substring(idx_s).trim();
            split.add(f);
        }
        //System.out.println("split.toString() = " + split.toString());
        return split;
    }
}

Related

  1. splitStringBySeperator(final String str, final String seperator)
  2. splitStrings(String start, String end, int numSplitStrings, boolean oddLevel, List splits)
  3. splitStringToList(String pstrString, String pstrSep)
  4. splitStringWithoutTrim(String strInput, String strSplitor)
  5. splitStruct(String struct)
  6. splitTags(final String tagsString)
  7. splitTags(String rawTags)
  8. splitTemplateName(String templateName)
  9. splitter(List list, final int L)