Here you can find the source of splitToCollection(Collection
private static void splitToCollection(Collection<String> collection, String valueString)
//package com.java2s; /************************************************************************************* * Copyright (c) 2014 Red Hat, Inc. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * // ww w .j a v a 2 s .co m * Contributors: * JBoss by Red Hat - Initial implementation. ************************************************************************************/ import java.util.Collection; public class Main { private static void splitToCollection(Collection<String> collection, String valueString) { String[] splitValues = valueString.split(",");//$NON-NLS-1$ for (String value : splitValues) { value = value.trim(); if (!value.isEmpty()) { collection.add(value); } } } }