Java String Split by Char splitAt(String str, char c)

Here you can find the source of splitAt(String str, char c)

Description

split At

License

Open Source License

Declaration

public static String[] splitAt(String str, char c) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

public class Main {
    public static String[] splitAt(String str, char c) {
        int index = str.indexOf(c);
        ArrayList<String> split = new ArrayList<String>();
        while (index != -1) {
            split.add(str.substring(0, index));
            str = str.substring(index + 1);
            index = str.indexOf(c);//w  w w.  java  2s.c om
        } //while
        split.add(str);
        String[] splitstring = split.toArray(new String[split.size()]);
        return splitstring;
    }
}

Related

  1. split(String string, char character)
  2. split(String toSplit, char splitChar, boolean trim)
  3. split(String val, char ch)
  4. split(String value, char splitChar)
  5. splitAt(String inputString, Character inputChar)
  6. splitByChar(final String message, final char ch)
  7. splitByNonNestedChars(String s, char... c)
  8. splitChars(String input, String charsToBeRemoved)
  9. splitEncolosed(String s, char open_tag, char close_tag)