Java String Split split(String str)

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

Description

split

License

Open Source License

Declaration

public static String[] split(String str) 

Method Source Code


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

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static String[] split(String str) {
        char[] chars = str.toCharArray();
        List<String> tokens = new ArrayList<>();
        StringBuilder buf = new StringBuilder();
        for (char aChar : chars) {
            if ((aChar >= 'a' && aChar <= 'z') || aChar == '\'') {
                buf.append(aChar);/*from w  ww  . j  av a  2  s  .c o m*/
            } else {
                if (buf.length() > 0) {
                    tokens.add(buf.toString());
                    buf = new StringBuilder();
                }
            }
        }
        if (buf.length() > 0) {
            tokens.add(buf.toString());
        }
        return tokens.toArray(new String[0]);
    }
}

Related

  1. split(String str)
  2. split(String str)
  3. split(String str)
  4. split(String str)
  5. split(String str)
  6. split(String str, int ch)
  7. split(String str, String id)
  8. split(String str, String splitStr)
  9. split(String str, String splitter)