Here you can find the source of toList(String text)
public static Collection<String> toList(String text)
//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; } }