Java CSV from getFixedArrayListSizeFromCSV(String csvString, int returnArrayListSize)

Here you can find the source of getFixedArrayListSizeFromCSV(String csvString, int returnArrayListSize)

Description

get Fixed Array List Size From CSV

License

Open Source License

Declaration

static public ArrayList<String> getFixedArrayListSizeFromCSV(String csvString, int returnArrayListSize) 

Method Source Code

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

import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    static final public String CSV_SEPARATOR = ",";

    static public ArrayList<String> getFixedArrayListSizeFromCSV(String csvString, int returnArrayListSize) {
        ArrayList<String> returnArray = getArrayListFromCSV(csvString);
        while (returnArray.size() < returnArrayListSize)
            returnArray.add("");
        return returnArray;
    }/*  w  ww  .  j a v a  2 s.c o  m*/

    static public ArrayList<String> getArrayListFromCSV(String csvString) {
        return helper1(csvString, CSV_SEPARATOR);
    }

    static private ArrayList<String> helper1(String ssvString, String separator) {
        if (ssvString.isEmpty())
            return new ArrayList<>(); // Return list with 0 elements as it should be!
        return new ArrayList<String>(Arrays.asList(ssvString.split(separator)));
    }
}

Related

  1. getCSVList(String csvList)
  2. getCSVList(String csvList)
  3. getCSVString(List items)
  4. getCsvStringsFromList(final List stringsToDelimit)
  5. getepcList(String csv)
  6. getListFromCSV(String myCsv)
  7. getListFromCSV(String myCsv)
  8. getListFromCSVString(String csvString)
  9. getPrintableCSVs(List list)