All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rrsunhome.excelsql.util.CSVResultSet Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package com.github.rrsunhome.excelsql.util;

import com.csvreader.CsvReader;

import java.io.IOException;

/**
 * @author : wangqijia
 * create at:  2020/11/10  上午10:43
 */
public class CSVResultSet {

    private int index;

    private CsvReader reader;

    public CSVResultSet(int index, CsvReader reader) {
        this.index = index;
        this.reader = reader;
    }

    public CSVResultSet(CsvReader reader) {
        this.reader = reader;
    }


    public String getString(int columnIndex) {
        try {
            return reader.get(columnIndex);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }

    public Long getLong(int columnIndex) {
        return Long.valueOf(getString(columnIndex));
    }

    public Long getLong(String columnLabel) {
        return Long.valueOf(getString(columnLabel));
    }

    public String getString(String columnLabel) {
        try {
            return reader.get(columnLabel);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }


    public String[] getValues() {
        try {
            return reader.getValues();
        } catch (IOException e) {
            return null;
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy