Java String Split splitElements(String values)

Here you can find the source of splitElements(String values)

Description

Split a list of values.

License

Open Source License

Parameter

Parameter Description
values The values list as a single string.

Return

The values.

Declaration

public static List<String> splitElements(String values) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static final String DEFAULT_VALUE_SEPARATOR = "~";

    /**/* ww w  .  j  av  a  2 s. com*/
     * Split a list of values.
     * 
     * @param values
     *            The values list as a single string.
     * @return The values.
     */
    public static List<String> splitElements(String values) {

        final ArrayList<String> list = new ArrayList<String>();

        try {
            if (values != null) {

                final String[] split = values.trim().split(DEFAULT_VALUE_SEPARATOR);

                if (split != null && split.length != 0) {
                    for (final String value : split) {
                        if (value != null) {
                            list.add(String.valueOf(value));
                        }
                    }
                }
            }
        } catch (ClassCastException e) {
            // digest exception.
        }

        return list;
    }
}

Related

  1. splitCamelback(String s)
  2. splitCQLStatements(String source)
  3. splitDateText(String text)
  4. splitDigits(long input)
  5. splitDomains(String domains)
  6. splitEx(String str, String spilter)
  7. splitFields(String fieldsString, int minNum)
  8. splitForIndexMatching(String string)
  9. splitGenericIfNeeded(String name)