Java String Explode explode(String handleStr, String pointStr)

Here you can find the source of explode(String handleStr, String pointStr)

Description

explode, separate string into a Vector

License

Apache License

Parameter

Parameter Description
handleStr a parameter
pointStr a parameter

Return

Vector, include separated string

Declaration

public static Vector explode(String handleStr, String pointStr) 

Method Source Code


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

import java.util.*;

public class Main {
    /**//  w w  w  .j a  va 2s  .c  om
     * explode, separate string into a Vector
     *
     * @param handleStr
     * @param pointStr
     * @return Vector, include separated string
     */
    public static Vector explode(String handleStr, String pointStr) {
        Vector v = new Vector();
        int pos1, pos2;
        try {
            if (handleStr.length() > 0) {
                pos1 = handleStr.indexOf(pointStr);
                pos2 = 0;
                while (pos1 != -1) {
                    v.addElement(handleStr.substring(pos2, pos1));
                    pos2 = pos1 + pointStr.length();
                    pos1 = handleStr.indexOf(pointStr, pos2);
                }
                v.addElement(handleStr.substring(pos2));
            }
        } catch (Exception error) {
            error.printStackTrace();
        }
        return v;
    }
}

Related

  1. explode(final String str, final char delimiter, final int limit)
  2. explode(int clr)
  3. explode(String csv)
  4. explode(String data, String delim)
  5. explode(String delim, String string)
  6. explode(String input, final char delimiter, final char escape, final int capacity)
  7. explode(String s, String delim)
  8. explode(String source, String deliminator)
  9. explode(String split, String input)