Java String Split by Separator split(String input, int separator)

Here you can find the source of split(String input, int separator)

Description

split

License

LGPL

Declaration

public static List<String> split(String input, int separator) 

Method Source Code

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

import java.util.*;

public class Main {
    public static List<String> split(String input, int separator) {
        List<String> retval = new ArrayList<String>();
        if (input == null)
            return retval;
        int index = 0, end;
        while (true) {
            index = input.indexOf(separator, index);
            if (index == -1)
                break;
            index++;//from   ww  w .j  a va 2 s. c om
            end = input.indexOf(separator, index);
            if (end == -1)
                retval.add(input.substring(index));
            else
                retval.add(input.substring(index, end));
        }
        return retval;
    }
}

Related

  1. split(final String str, final char[] separators)
  2. split(final String text, final char separator)
  3. split(final String text, final String separator)
  4. split(final T string, final char separator)
  5. split(String array, String separators)
  6. split(String left, String separator)
  7. split(String s, char separator)
  8. split(String s, char separator)
  9. split(String s, char separator)