Java List Transform transformStringToListOfStrings(String line)

Here you can find the source of transformStringToListOfStrings(String line)

Description

transform String To List Of Strings

License

Open Source License

Declaration

static public List<String> transformStringToListOfStrings(String line) 

Method Source Code


//package com.java2s;
/*/*from   w ww. j av a 2  s .  co m*/
 *  Basics_Utils.java
 *
 *  chess383 is a collection of chess related utilities.
 *  Copyright (C) 2016 J?rg Dippel
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU 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 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 {
    static public List<String> transformStringToListOfStrings(String line) {

        if (line == null || line.trim().length() == 0)
            return (new ArrayList<String>(0));

        String[] tokens = line.trim().split("\\s+");
        int tokensLength = tokens.length;
        List<String> result = new ArrayList<String>(tokensLength);
        for (int index = 0; index < tokensLength; index++) {
            result.add(tokens[index]);
        }

        return (result);
    }
}

Related

  1. transformCollectionTOList(Collection collection)
  2. transformContinuouslyVariablesByThreshold(List> data, int index, int threshold)
  3. transformIntoAList(String... elements)
  4. transformNumberedPropertiesToList(Properties props)
  5. transformStringListToString(List fileContentAsList)
  6. transformToDoublePrimitiveArray( List values)
  7. transformToJsonArray(List objectsWithJsonToString)