2026/3/3 13:50:27
网站建设
项目流程
阿里去要企业网站建设方案书,网络品牌推广策划方案,兰州市城乡建设局网站官网,希音跨境电商官网入口文章目录 概要整体架构流程技术名词解释技术细节小结 基本解压
基础解压#xff0c;仅实现将输入压缩包解压到指定文件夹下
代码如下#xff1a;
package weaver.formmode.webservices;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.z…文章目录概要整体架构流程技术名词解释技术细节小结基本解压基础解压仅实现将输入压缩包解压到指定文件夹下代码如下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 组件拼接在一起形成的。技术名词解释提示这里可以添加技术名词解释例如BertGPT 初代GPT-2GPT-3ChatGPT技术细节提示这里可以添加技术细节例如API支持模型类型小结提示这里可以添加总结例如提供先进的推理复杂的指令更多的创造力。