Java String Split splitInput(String cliInput)

Here you can find the source of splitInput(String cliInput)

Description

Splits the input of comma separated command line input and returns the results as an arraylist.

License

Apache License

Parameter

Parameter Description
cliInput the CLI input

Return

an arraylist containing the results, empty list if empty string

Declaration

public static ArrayList<String> splitInput(String cliInput) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

public class Main {
    /**//  w  ww.j a  v  a  2 s  . com
     * The command line argument separator.
     */
    public static final String SEPARATOR = ",";

    /**
     * Splits the input of comma separated command line input and returns the
     * results as an arraylist.
     *
     * @param cliInput the CLI input
     * 
     * @return an arraylist containing the results, empty list if empty string
     */
    public static ArrayList<String> splitInput(String cliInput) {
        ArrayList<String> results = new ArrayList<String>();

        // empty input, return the empty list
        if (cliInput == null || cliInput.trim().length() == 0) {
            return results;
        }

        for (String tempInput : cliInput.split(SEPARATOR)) {
            results.add(tempInput.trim());
        }
        return results;
    }
}

Related

  1. splitHelperName(String name)
  2. splitHistory(String history)
  3. splitHTMLTags(final String string)
  4. splitIdKeyConfig(String config)
  5. splitInitialItems(final String text)
  6. splitIntArray(final String iInput)
  7. splitIntegerFromString(String str)
  8. splitIntegerPerDigit(int i)
  9. splitIntoPackages(String stmt)