easyexcel解析csv文件
创始人
2024-11-14 15:05:28
0

背景:接着上一篇下载文件,从ftp下载到csv文件后,解析转换成想要的数据存储数据库,此处设计成用easyexcel读取csv中的数据,并转换成自己想要的格式,这里选easyexcel的原因就是因为简单,下面将逐步解释如何使用以及在使用中需要注意的事项。

引入依赖

                              com.alibaba             easyexcel             3.1.2                                        org.apache.ant             ant             1.7.0          

检查文件是否存在

listFiles是上一篇的方法
sourceOpt为真代表存在

List files = sftpHelper.listFiles(sftpPathAll); Optional sourceOpt = files.stream().filter(f -> f.equals(fileName)).findFirst(); 

下载文件

downloadFile是上一篇的方法

sftpHelper.downloadFile(sftpPathAll, fileName, savePathAll); 

解压文件

unZip方法是解压操作

package x.x.infra.util;  import java.io.*; import java.nio.charset.Charset; import java.util.Enumeration;  import lombok.extern.slf4j.Slf4j; import org.apache.tools.zip.ZipEntry; import org.apache.tools.zip.ZipFile; import org.apache.tools.zip.ZipOutputStream;  @Slf4j public class ZipFileUtils {         private static int bufferSize = 2048;      /**      * 解压到指定目录      */     public static void unZip(String zipPath, String descDir) throws IOException {             unZip(new File(zipPath), descDir);     }      /**      * 解压文件到指定目录      */     @SuppressWarnings("rawtypes")     public static void unZip(File zipFile, String descDir) throws IOException {             File pathFile = new File(descDir);         if (!pathFile.exists()) {                 pathFile.mkdirs();         }         //解决zip文件中有中文目录或者中文文件 //        ZipFile zip = new ZipFile(zipFile, Charset.forName("GBK"));         ZipFile zip = new ZipFile(zipFile);         for (Enumeration entries = zip.getEntries(); entries.hasMoreElements(); ) {                 ZipEntry entry = (ZipEntry) entries.nextElement();             String zipEntryName = entry.getName();             InputStream in = zip.getInputStream(entry);             String outPath = (descDir + zipEntryName).replaceAll(

相关内容

热门资讯

智星德州菠萝插件官网!hhpo... 智星德州菠萝插件官网!hhpoker透视脚本下载(透视)一贯有挂(安装教程)1、完成hhpoker透...
透视规律!德普之星辅助功能如何... 透视规律!德普之星辅助功能如何打开,hhpoker开辅助软件,必备辅助推荐(有挂黑科技)(1)透视规...
透视肯定!aapoker辅助包... 透视肯定!aapoker辅助包,wepoker辅助下载,软件教程(有挂黑科技);1、玩家可以在wep...
德州ai辅助有用!aapoke... 德州ai辅助有用!aapoker外挂(透视)总是真的是有挂(详细辅助科技通报)1、玩家可以在德州ai...
透视游戏!aapoker透视软... 您好,aapoker透视软件这款游戏可以开挂的,确实是有挂的,需要了解加微【136704302】很多...
wepoker底牌透视脚本!w... wepoker底牌透视脚本!wepoker买钻石有用吗(透视)真是是真的有挂(切实教程)暗藏猫腻,小...
透视计算!wpk辅助器,红龙p... 透视计算!wpk辅助器,红龙poker脚本,可靠教程(有挂规律)1、用户打开应用后不用登录就可以直接...
WePoKe透明挂!wpk俱乐... 1、WePoKe透明挂!wpk俱乐部(透视)往昔有挂(详细辅助实测揭晓);详细教程。2、WePoKe...
透视挂!wpk辅助器,aapk... 透视挂!wpk辅助器,aapkoer德州辅助挂下载,玩家必看科普(有挂规律)1、aapkoer德州辅...
hhpoker免费透视脚本!h... hhpoker免费透视脚本!hhpoker底牌透视脚本(透视)果然真的有挂(微扑克教程)1、每一步都...