Java String Split split(String toSplit)

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

Description

split

License

Apache License

Declaration

public static List<String> split(String toSplit) 

Method Source Code


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

import java.util.*;

public class Main {
    public static List<String> split(String toSplit) {
        return split(toSplit, null, false);
    }/*from  w  w w.ja  v  a 2s.c o  m*/

    public static List<String> split(String toSplit, String delims) {
        return split(toSplit, delims, false);
    }

    public static List<String> split(String toSplit, String delims, boolean splitByRegex) {
        if (toSplit == null)
            return null;
        StringTokenizer st = null;
        List<String> toRet = null;
        if (!splitByRegex) {
            toRet = new ArrayList<String>();
            if (delims != null)
                st = new StringTokenizer(toSplit, delims);
            else
                st = new StringTokenizer(toSplit);
            while (st.hasMoreTokens()) {
                toRet.add(st.nextToken().trim());
            }
        } else {
            String[] array = toSplit.split(delims);
            toRet = new ArrayList<String>(Arrays.asList(array));
        }
        return toRet;
    }
}

Related

  1. split(String text)
  2. split(String text)
  3. split(String text)
  4. split(String text, String token)
  5. split(String token, String s)
  6. split(String value)
  7. split(String value)
  8. split_fields(String str)
  9. split_str(String input, String split)