Java String Split split(String s)

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

Description

Splits on whitespace (\\s+).

License

Open Source License

Parameter

Parameter Description
s String to split

Return

List of split strings

Declaration

public static List<String> split(String s) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    /**/*w  w  w .j a v a  2s . co m*/
     * Splits on whitespace (\\s+).
     * @param s String to split
     * @return List<String> of split strings
     */
    public static List<String> split(String s) {
        return split(s, "\\s+");
    }

    /**
     * Splits the given string using the given regex as delimiters.
     * This method is the same as the String.split() method (except it throws
     * the results in a List),
     * and is included just to give a call that is parallel to the other
     * static regex methods in this class.
     *
     * @param str   String to split up
     * @param regex String to compile as the regular expression
     * @return List of Strings resulting from splitting on the regex
     */
    public static List<String> split(String str, String regex) {
        return (Arrays.asList(str.split(regex)));
    }
}

Related

  1. split(String input)
  2. split(String input)
  3. split(String input)
  4. split(String s)
  5. split(String s)
  6. split(String s)
  7. split(String s)
  8. split(String s, int c)
  9. split(String s, String at)