Java String Split split(String s)

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

Description

Splits on whitespace (\\s+).

License

Apache License

Declaration

public static List split(String s) 

Method Source Code

//package com.java2s;
/*-/*w  w  w.j ava  2 s. co  m*/
 *
 *  * Copyright 2015 Skymind,Inc.
 *  *
 *  *    Licensed under the Apache License, Version 2.0 (the "License");
 *  *    you may not use this file except in compliance with the License.
 *  *    You may obtain a copy of the License at
 *  *
 *  *        http://www.apache.org/licenses/LICENSE-2.0
 *  *
 *  *    Unless required by applicable law or agreed to in writing, software
 *  *    distributed under the License is distributed on an "AS IS" BASIS,
 *  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  *    See the License for the specific language governing permissions and
 *  *    limitations under the License.
 *
 */

import java.util.*;

public class Main {
    /**
     * Splits on whitespace (\\s+).
     */
    public static List 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 split(String str, String regex) {
        return (Arrays.asList(str.split(regex)));
    }
}

Related

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