导入zip文件解析
2024-09-18 16:12:27
/**
* 导入压缩文件
*
* @param file
* @param charsetName
* @param consumer
*/
public static void importZipFile(MultipartFile file, String charsetName, ThrowExceptionBiConsumer<ZipInputStream, ZipEntry> consumer)
{
try (ZipInputStream zipInputStream = new ZipInputStream(file.getInputStream(), Charset.forName(charsetName)))
{
while (true)
{
ZipEntry nextEntry = zipInputStream.getNextEntry(); if (nextEntry == null)
{
break;
} consumer.accept(zipInputStream, nextEntry);
}
}
catch (Exception e)
{
log.error(e.getMessage(), e);
throw new BaseException(e.getMessage(), e);
}
}
/**
* 抛出异常函数接口
*
* @author
* @date 2021/5/13
*/
@FunctionalInterface
public interface ThrowExceptionBiConsumer<T, U>
{
/**
* 对给定参数执行此操作
*
* @param t
* @param u
* @throws Exception
*/
void accept(T t, U u) throws Exception;
}
最新文章
- iOS之在webView中引入本地html,image,js,css文件的方法 - sky//////////////////////////////////////ZZZZZZZZZZZZZZZ
- interview que
- 大话设计模式C++版——代理模式
- LR接口测试手工脚本与验证脚本
- C#的winform拼数字游戏
- zy 送画
- thinkphp ajax 实例 实现
- 关于chrome浏览器更新后快捷工具失效的解决方法
- T-SQL变量
- ajax 中文乱码
- Android App监听软键盘按键的三种方式(转)
- CF585E. Present for Vitalik the Philatelist [容斥原理 !]
- JAVA简便解析json文件
- Go语言Context(设计及分析)
- Nginx服务器中的Socket切分,需要的朋友可以参考下
- 18.7 修改IP地址
- MIUI通过xposed自动设置root权限
- 文件I/O操作
- [转]如何远程连接运行OpenGL/Cuda 等GPU程序
- mongodb副本集升级步骤
热门文章
- 08-通用Service接口
- C语言读写txt文件
- overflow_auto在flex_1的容器失效
- 3、swagger调试
- Kali-Linux-for-Docker
- Java8时间日期处理新特性
- Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level
- mysql基础命令语法
- [深度探索C++对象模型]trival constructor和non-trival constructor
- LCD副屏-CPU,内存,时显,日期显示