Here you can find the source of splitSpaces(String input)
Parameter | Description |
---|---|
input | The input string |
public static List<String> splitSpaces(String input)
//package com.java2s; /*/*from w ww.ja v a2s .c o m*/ LWKT - A light WKT parser written in Java Copyright (C) 2011 Francesco Cutruzzula' (www.cutruzzula.it) This library 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 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ import java.util.ArrayList; import java.util.List; public class Main { /** Method to split a string using spaces ("/\\s+/" regex). * @param input The input string * @return A java.util.List<String> with tokens != "" */ public static List<String> splitSpaces(String input) { List<String> results = new ArrayList<String>(); String parts[] = input.split("\\s+"); for (int i = 0; i < parts.length; i++) { if (parts[i].length() > 0) { results.add(parts[i]); } } return results; } }