news 2026/4/23 15:31:24

文件多级解压

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
文件多级解压

文章目录

    • 概要
    • 整体架构流程
    • 技术名词解释
    • 技术细节
    • 小结

基本解压

基础解压,仅实现将输入压缩包解压到指定文件夹下

代码如下:

package weaver.formmode.webservices; import java.io.*; import java.nio.charset.StandardCharsets; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; // 根据传入的压缩包实现解压缩到指定位置,当含有多个压缩包要递归解压,包含文件夹要把文件夹删除,解压结果仅保持一级结构 public class ExtractDemo { // Extract the files from the archive. /** 默认 4 KB 缓冲 */ private static final int BUFFER = 4096; /** * 解压 ZIP 到指定目录 * @param zipFilePath 压缩包绝对路径 * @param destDirPath 目标目录(若不存在则自动创建) * @throws IOException 解压失败时抛出 */ public static void unzip(String zipFilePath, String destDirPath) throws IOException { unzip(zipFilePath, destDirPath, null); } /** * 带进度回调的解压 * @param zipFilePath 压缩包绝对路径 * @param destDirPath 目标目录(若不存在则自动创建) * @param callback 进度回调(可为 null) * @throws IOException 解压失败时抛出 */ public static void unzip(String zipFilePath, String destDirPath, ProgressCallback callback) throws IOException { File destDir = new File(destDirPath); if (!destDir.exists()) destDir.mkdirs(); try (ZipInputStream zis = new ZipInputStream( new BufferedInputStream(new FileInputStream(zipFilePath)), StandardCharsets.UTF_8)) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { String entryName = entry.getName(); File outFile = new File(destDir, entryName); // 防止 zip 炸弹(../ 跳出目标目录) if (!outFile.getCanonicalPath().startsWith(destDir.getCanonicalPath() + File.separator)) { throw new IOException("非法路径: " + entryName); } if (entry.isDirectory()) { outFile.mkdirs(); } else { outFile.getParentFile().mkdirs(); try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(outFile))) { byte[] buffer = new byte[BUFFER]; int len; while ((len = zis.read(buffer)) != -1) { bos.write(buffer, 0, len); } } } zis.closeEntry(); if (callback != null) callback.onEntry(entryName, outFile.length()); } } } /** 进度回调接口 */ @FunctionalInterface public interface ProgressCallback { void onEntry(String entryName, long bytesWritten); } public static void main(String[] args) throws Exception { String zip = "D:\\DATA\\DS.zip"; String dir = "D:\\DATA\\duckcp-main"; unzip(zip, dir, (name, size) -> System.out.println("解压中 -> " + name + " " + size + " B")); } }

整体架构流程

提示:这里可以添加技术整体架构

例如:
在语言模型中,编码器和解码器都是由一个个的 Transformer 组件拼接在一起形成的。

技术名词解释

提示:这里可以添加技术名词解释

例如:

  • Bert
  • GPT 初代
  • GPT-2
  • GPT-3
  • ChatGPT

技术细节

提示:这里可以添加技术细节

例如:

  • API
  • 支持模型类型

小结

提示:这里可以添加总结

例如:

提供先进的推理,复杂的指令,更多的创造力。

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/23 14:36:07

3步解锁音乐加密:网易云QQ音乐自由播放终极指南

3步解锁音乐加密:网易云QQ音乐自由播放终极指南 【免费下载链接】unlock-music 音乐解锁:移除已购音乐的加密保护。 目前支持网易云音乐(ncm)、QQ音乐(qmc, mflac, tkm, ogg) 。原作者也不知道是谁() 项目地址: https://gitcode…

作者头像 李华
网站建设 2026/4/23 11:34:29

Arch-Hyprland终极桌面配置:5分钟打造现代化工作环境

Arch-Hyprland终极桌面配置:5分钟打造现代化工作环境 【免费下载链接】Arch-Hyprland For automated installation of Hyprland on Arch on any arch based distros 项目地址: https://gitcode.com/gh_mirrors/ar/Arch-Hyprland Arch-Hyprland是一款专为Arch…

作者头像 李华
网站建设 2026/4/23 11:32:49

鼠须管输入法:macOS上的极致中文输入体验

鼠须管输入法:macOS上的极致中文输入体验 【免费下载链接】squirrel 项目地址: https://gitcode.com/gh_mirrors/squi/squirrel 如果你正在寻找一款能够完美融合macOS生态、兼具优雅设计与强大功能的中文输入法,鼠须管输入法绝对值得你深入了解。…

作者头像 李华
网站建设 2026/4/23 11:34:39

Epic Games免费游戏自动领取助手使用全攻略

还在为错过Epic Games每周免费游戏而烦恼吗?这款智能领取小帮手将彻底解放您的双手,让您轻松获取每一款免费游戏,构建专属游戏库从未如此简单! 【免费下载链接】epicgames-freebies-claimer Claim available free game promotions…

作者头像 李华
网站建设 2026/4/23 11:33:15

Wayback Machine 网页时光机:找回消失网页的完整解决方案

Wayback Machine 网页时光机:找回消失网页的完整解决方案 【免费下载链接】wayback-machine-webextension A web browser extension for Chrome, Firefox, Edge, and Safari 14. 项目地址: https://gitcode.com/gh_mirrors/wa/wayback-machine-webextension …

作者头像 李华
网站建设 2026/4/18 15:53:11

Charticulator零代码可视化设计完全指南

Charticulator零代码可视化设计完全指南 【免费下载链接】charticulator Interactive Layout-Aware Construction of Bespoke Charts 项目地址: https://gitcode.com/gh_mirrors/ch/charticulator 还在为传统图表工具的局限性而困扰吗?Charticulator作为微软…

作者头像 李华