package com.saye.hospitalgd.util;

import com.opencsv.CSVReader;
import com.opencsv.exceptions.CsvException;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @author： Mr.zs
 * @date： 2022/12/15
 * @description：
 * @modifiedBy：
 * @version: 1.0
 */
public class CSVUtils {

    public static List<String[]> getCsvData(InputStream file) {


        System.out.println("********************");
        InputStreamReader isr = null;
        try {
            isr = new InputStreamReader(file, "gbk");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        CSVReader reader = new CSVReader(isr);
        List<String[]> allList = null;
        try {
            allList = reader.readAll();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (CsvException e) {
            e.printStackTrace();
        }

        return allList;

    }
}