Java String Split Split(String content, String sub_seq)

Here you can find the source of Split(String content, String sub_seq)

Description

Split

License

Apache License

Declaration

public static String[] Split(String content, String sub_seq) 

Method Source Code


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

import java.util.ArrayList;

public class Main {
    public static String[] Split(String content, String sub_seq) {
        int start_index = 0;
        ArrayList<String> ret = new ArrayList<String>();

        int pos = -1;
        while (start_index < content.length() && (pos = content.indexOf(sub_seq, start_index)) != -1) {
            ret.add(content.substring(start_index, pos + sub_seq.length()));
            start_index = pos + sub_seq.length();
        }/*from w ww  .  j  ava 2 s .co  m*/
        if (start_index < content.length()) {
            ret.add(content.substring(start_index));
        }
        String[] result = new String[ret.size()];
        return ret.toArray(result);
    }
}

Related

  1. split(Iterable objects, boolean even)
  2. split(String arg)
  3. split(String candidate)
  4. split(String cmd)
  5. split(String content)
  6. split(String input)
  7. split(String input)
  8. split(String input)
  9. split(String s)