Java String to List toList(String text)

Here you can find the source of toList(String text)

Description

to List

License

Open Source License

Declaration

public static Collection<String> toList(String text) 

Method Source Code


//package com.java2s;
/*/*from w w w.ja v  a 2s  .  c  o  m*/
 * Copyright (C) 2018 MineStar.de
 *
 * This file is part of MoneyPit.
 *
 * MoneyPit 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, version 3 of the License.
 *
 * MoneyPit 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 MoneyPit.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

public class Main {
    private static String DELIMITER = ";";

    public static Collection<String> toList(String text) {
        HashSet<String> list = null;
        if (text == null) {
            return list;
        }

        String[] split = text.split(DELIMITER);
        if (split == null || split.length == 0) {
            return list;
        }

        list = new HashSet<>();
        Collections.addAll(list, split);

        return list;
    }
}

Related

  1. toList(String s, String delim)
  2. toList(String s, String delimiter)
  3. toList(String str)
  4. toList(String str)
  5. toList(String string)
  6. toList(String transaction)
  7. toList(String val)
  8. toList(String val, String separator)