Here you can find the source of split(String s)
public static List split(String s)
//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))); } }