Android String Split splitStringOnWhitespace(String stringToSplit)

Here you can find the source of splitStringOnWhitespace(String stringToSplit)

Description

split String On Whitespace

License

Open Source License

Parameter

Parameter Description
stringToSplit the string to split on whitespace.

Return

the split string as a list.

Declaration

public static List<String> splitStringOnWhitespace(String stringToSplit) 

Method Source Code

//package com.java2s;
/**/*w ww.  j  a v  a  2 s.  c  om*/
 * Copyright (c) 2012-2013 by European Organization for Nuclear Research (CERN)
 * Author: Justin Salmon <jsalmon@cern.ch>
 *
 * This file is part of the Mock TeamCity plugin.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**
     * @param stringToSplit the string to split on whitespace.
     *
     * @return the split string as a list.
     */
    public static List<String> splitStringOnWhitespace(String stringToSplit) {
        String[] array = stringToSplit.split("\\s+");
        List<String> list = new ArrayList<String>();

        for (int i = 0; i < array.length; i++) {
            list.add(array[i]);
        }

        return list;
    }
}

Related

  1. strToArray(String string, String delim)
  2. getStringArray(String str)
  3. split(String source, String separator, int arraylength)
  4. split(String str, String delims, boolean trimTokens)
  5. stringToListStr(String input)
  6. stringToListByLine(final String fileContent)
  7. split(String str, String separatorChars)
  8. split(String str, char delimiter)
  9. split(String str, char separator)