public class ZipUtil extends Object
| Modifier and Type | Field and Description |
|---|---|
private static int |
BUFFER |
private static org.slf4j.Logger |
log |
| Modifier | Constructor and Description |
|---|---|
private |
ZipUtil() |
| Modifier and Type | Method and Description |
|---|---|
private static void |
compress(File file,
ZipOutputStream zipOut,
String baseDir,
boolean root)
压缩文件
|
static void |
compress(String fromPath,
String toPath)
压缩文件夹
|
private static void |
compressDirectory(File dir,
ZipOutputStream zipOut,
String baseDir,
boolean root)
压缩文件夹
|
private static void |
compressFile(File file,
ZipOutputStream zipOut,
String baseDir)
压缩文件
|
private static ByteArrayOutputStream |
createZip(String sourceFilePath)
创建zip文件
|
static void |
exportZip(javax.servlet.http.HttpServletResponse response,
String sourceFilePath,
String postfix)
将指定路径下的所有文件打包zip导出
|
private static final int BUFFER
private static final org.slf4j.Logger log
public static void exportZip(javax.servlet.http.HttpServletResponse response,
String sourceFilePath,
String postfix)
response - responsesourceFilePath - 需要打包的文件夹路径postfix - 下载时的文件后缀 .zip/.rarpublic static void compress(String fromPath, String toPath)
fromPath - 目录toPath - 目录private static ByteArrayOutputStream createZip(String sourceFilePath)
sourceFilePath - 源文件目录private static void compress(File file, ZipOutputStream zipOut, String baseDir, boolean root) throws IOException
file - 文件zipOut - zipOutbaseDir - 目录root - 是否根目录IOException - 异常private static void compressFile(File file, ZipOutputStream zipOut, String baseDir) throws IOException
file - 文件zipOut - zipOutbaseDir - 目录IOException - 异常private static void compressDirectory(File dir, ZipOutputStream zipOut, String baseDir, boolean root) throws IOException
dir - 文件zipOut - zipOutbaseDir - 目录root - 是否为根目录IOException - 异常Copyright © 2024. All rights reserved.