Java CSV from csvList(String _text, Integer[] _idx_ret)

Here you can find the source of csvList(String _text, Integer[] _idx_ret)

Description

Kommaseparierte Werteliste in String[] umwandeln.

License

Open Source License

Parameter

Parameter Description
_text a parameter
_idx_ret a parameter

Declaration

public static String[] csvList(String _text, Integer[] _idx_ret) 

Method Source Code

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

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

public class Main {
    /**// ww w . j  a v a 2s  . com
     * Kommaseparierte Werteliste in String[] umwandeln.
     * 
     * Trennzeichen ist ','
     * 
     * @param _text
     * @param _idx_ret
     * @return
     */
    public static String[] csvList(String _text, Integer[] _idx_ret) {
        List<String> list = new ArrayList<String>();
        int idx = 0;
        boolean bCont = true;
        int idxr;
        do {
            idxr = _text.indexOf(',', idx);
            if (idxr == -1) {
                idxr = _text.length();
                bCont = false;
            }
            list.add(_text.substring(idx, idxr).trim());
            idx = idxr + 1;
        } while (bCont);

        _idx_ret[0] = (idxr + 1);

        String[] ret = new String[list.size()];
        list.toArray(ret);
        return ret;
    }

    public static String substring(String _text, int _idx) {
        if (_idx >= 0) {
            if (_idx < _text.length()) {
                return _text.substring(_idx);
            }
        }
        return "";
    }
}

Related

  1. convertListToCSVString(List list)
  2. convertStringListToCSV(List inputStringList)
  3. convertStringListToCSV(List source)
  4. countMaxColumnSizeByArray(List csvs)
  5. csv2list(String csvString)
  6. csvTagsToList(String tags)
  7. csvToList(String csv)
  8. csvToList(String csv)
  9. CSVToList(String str)