Java String Split split(final String str)

Here you can find the source of split(final String str)

Description

split

License

Open Source License

Declaration

static List<String> split(final String str) 

Method Source Code

//package com.java2s;
/********************************************************************************
 * Copyright (c) 2009 Regents of the University of Minnesota
 *
 * This Software was written at the Minnesota Supercomputing Institute
 * http://msi.umn.edu/*from w ww  . java  2 s. c  o  m*/
 *
 * All rights reserved. The following statement of license applies
 * only to this file, and and not to the other files distributed with it
 * or derived therefrom.  This file is 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:
 * Minnesota Supercomputing Institute - initial API and implementation
 *******************************************************************************/

import java.util.ArrayList;

import java.util.List;
import java.util.Arrays;

public class Main {
    static List<String> split(final String str) {
        if (str.contains(",")) {
            @SuppressWarnings("unchecked")
            final List<String> splitValues = Arrays.asList(str.split(","));
            return splitValues;
        } else {
            final List<String> values = new ArrayList<String>(1);
            values.add(str);
            return values;
        }
    }
}

Related

  1. split(final byte[] array, final int chunkSize)
  2. split(final int limit, String text)
  3. split(final String s)
  4. split(final String s)
  5. split(final String s)
  6. split(final String str)
  7. split(final String string)
  8. split(final String string)
  9. split(final String string, final String toSplit)