Java Collection Create createCollectionFromString(String value)

Here you can find the source of createCollectionFromString(String value)

Description

create Collection From String

License

Open Source License

Declaration

public static Collection createCollectionFromString(String value) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 EclipseSource 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
 *
 * Contributors://  w  w w .  j  a v  a  2  s.co m
 *   EclipseSource - initial API and implementation
 ******************************************************************************/

import java.util.*;

public class Main {
    private static final String COLLECTION_SEPARATOR = ",";

    public static Collection createCollectionFromString(String value) {
        if (value == null) {
            return null;
        }
        final StringTokenizer t = new StringTokenizer(value,
                COLLECTION_SEPARATOR);
        final List result = new ArrayList();
        while (t.hasMoreTokens()) {
            result.add(t.nextToken());
        }
        return result;
    }
}

Related

  1. createCollection( final Iterable object)
  2. createCollection(Collection col)
  3. createCollection(Object[] objects)
  4. createCollection(T... items)
  5. createCollection(X o)
  6. createCSV(Collection list)
  7. createCsvString(Collection in)
  8. createFloatArray(java.util.Collection collection)
  9. createInstance( Class collectionType)