Java Comma Separated List convertToStringList(String valuesCommaSeparated)

Here you can find the source of convertToStringList(String valuesCommaSeparated)

Description

Convert a String List.

License

Apache License

Parameter

Parameter Description
valuesCommaSeparated the values comma separated

Return

the string

Declaration

public static List<String> convertToStringList(String valuesCommaSeparated) 

Method Source Code


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

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

public class Main {
    /**//ww  w.ja v a2s  .  c o m
     * Convert a String List.
     *
     * @param valuesCommaSeparated the values comma separated
     * @return the string
     */
    public static List<String> convertToStringList(String valuesCommaSeparated) {
        List<String> stringValues = new ArrayList<>();
        if (valuesCommaSeparated != null) {
            for (String value : valuesCommaSeparated.split(",")) {
                if (!isBlank(value)) {
                    stringValues.add(value);
                }
            }
        }
        return stringValues;
    }

    /**
     * Checks if is blank (null or lenght = 0).
     *
     * @param value the value
     * @return true, if is blank
     */
    public static boolean isBlank(String value) {
        return value == null || value.trim().isEmpty();
    }
}

Related

  1. commaSeperatedStringToList(String strValue)
  2. commaSepLineToList(String commSepLine)
  3. commaStringToList(String inputString)
  4. convertCommaDelimitedStringToList(String s)
  5. ConvertDiscussionGroupListToCommaString( List list)
  6. extractCommaItems(List list, String tags)
  7. extractCommandsFromLine(final String line, final String delimiter, final StringBuilder bufferedCommand, final List extractedCommands)
  8. formatCommand(List arguments)
  9. getAsCommaDelimitedString(List coll)