Here you can find the source of splitStringOnWhitespace(String stringToSplit)
Parameter | Description |
---|---|
stringToSplit | the string to split on whitespace. |
public static List<String> splitStringOnWhitespace(String stringToSplit)
//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; } }