Java String Split by Delimiter split(String str, String delimeter)

Here you can find the source of split(String str, String delimeter)

Description

split

License

Open Source License

Declaration

public static String split(String str, String delimeter) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;
import java.util.List;

public class Main {
    /** @METHOD */
    public static String split(String str, String delimeter) {
        List<String> subStrList = new ArrayList<String>();
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            if (Character.isUpperCase(str.charAt(i))) {
                subStrList.add(buf.toString());
                buf.setLength(0);//from w w w  .j  av  a 2 s . c o m
            }
            buf.append(str.charAt(i));
        }
        subStrList.add(buf.toString());

        buf = new StringBuilder();
        if (subStrList.isEmpty() == false) {
            for (int i = 0; i < subStrList.size(); i++) {
                String elem = subStrList.get(i);
                buf.append(elem);
                if (i != subStrList.size() - 1)
                    buf.append(delimeter);
            }
        }
        return buf.toString();
    }
}

Related

  1. split(String str, String delim)
  2. split(String str, String delim)
  3. split(String str, String delim)
  4. split(String str, String delim)
  5. split(String str, String delim)
  6. split(String str, String delimiter)
  7. split(String str, String delimiter)
  8. split(String str, String delimiter)
  9. split(String str, String delimiter)