Here you can find the source of slice(String line)
Parameter | Description |
---|---|
line | The line to be sliced |
public static String[] slice(String line)
//package com.java2s; /*/* www .j a v a 2s.com*/ * Mentawai Web Framework http://mentawai.lohis.com.br/ * Copyright (C) 2005 Sergio Oliveira Jr. (sergio.oliveira.jr@gmail.com) * * 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 St, Fifth Floor, Boston, MA 02110-1301 USA */ public class Main { /** * Turns a line with strings separated by one * or more spaces into a String array. * * @param line The line to be sliced * @return A String array with the slices */ public static String[] slice(String line) { return line.trim().split("\\s+"); } public static String[] split(String line) { String[] s = new String[line.length()]; for (int i = 0; i < line.length(); i++) { s[i] = String.valueOf(line.charAt(i)); } return s; } }