Java String Index Of splitUsingIndexOf(String splittee, String splitter)

Here you can find the source of splitUsingIndexOf(String splittee, String splitter)

Description

split Using Index Of

License

Open Source License

Declaration

public static String[] splitUsingIndexOf(String splittee, String splitter) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    public static String[] splitUsingIndexOf(String splittee, String splitter) {
        ArrayList<String> list = new ArrayList<String>();
        splittee += " " + splitter;

        int pos = 0, end;
        while ((end = splittee.indexOf(splitter, pos)) >= 0) {
            list.add(splittee.substring(pos, end).trim());
            pos = end + 1;/*from w ww . j a v  a 2 s .  c om*/
        }
        String[] result = new String[list.size()];
        for (int i = 0; i < result.length; i++) {
            result[i] = list.get(i);
        }

        return result;
    }
}

Related

  1. lastIndexOf(String pattern, String s)
  2. lastIndexOfIgnoreCase(final String s, final String subS)
  3. mergeStringLines(String lineOne, String lineTwo, int keyIndex, int insertingIndex)
  4. readColumn(int columnIndex, String inputString, String columnSeparator)
  5. removeColumn(String line, int index)
  6. sub(String string, int fromIndex, int toIndex)
  7. subStringChinese(String str, int startIndex, int endIndex)