Java Collection Split splitToCollection(Collection collection, String valueString)

Here you can find the source of splitToCollection(Collection collection, String valueString)

Description

split To Collection

License

Open Source License

Declaration

private static void splitToCollection(Collection<String> collection, String valueString) 

Method Source Code

//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);
            }
        }
    }
}

Related

  1. split(Collection collections, String separator)
  2. split(Collection orig, int batchSize)
  3. split(Collection set, int n)
  4. split(final Collection collection)
  5. splitAndKeepEscapedSpaces(String string, boolean preserveEscapes, Collection into)
  6. splitToCollection(String list, String separator, Collection dest)
  7. splitToCollection(String str, String sep, Collection c)