Class ZipUtil

java.lang.Object
com.sure.tool.io.ZipUtil

public class ZipUtil extends Object
ZIP 压缩解压工具类,参考 Hutool 的 ZipUtil 设计。

English: ZIP compression and extraction helpers.

Since:
0.1.0
Author:
suretool
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    unzip(File zipFile, File outDir)
    解压 zip 文件到目标目录(UTF-8 文件名)。
    static void
    unzip(File zipFile, File outDir, Charset charset)
    解压 zip 文件到目标目录。
    static void
    unzip(String zipPath, String outDirPath)
    解压 zip 文件到目标目录(路径字符串版本)。
    static void
    zip(File src, File zipFile)
    压缩文件或目录到 zip 文件(UTF-8 文件名)。
    static void
    zip(File src, File zipFile, Charset charset)
    压缩文件或目录到 zip 文件。
    static void
    zip(String srcPath, String zipPath)
    压缩文件或目录到 zip 文件(路径字符串版本)。
    static void
    zip(List<File> srcList, File zipFile)
    将多个文件/目录打包为 zip。
    static void
    zip(List<File> srcList, File zipFile, Charset charset)
    将多个文件/目录打包为 zip。

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • zip

      public static void zip(File src, File zipFile) throws IOException
      压缩文件或目录到 zip 文件(UTF-8 文件名)。
      Parameters:
      src - 源文件或目录
      zipFile - 目标 zip 文件
      Throws:
      IOException - IO 异常
    • zip

      public static void zip(File src, File zipFile, Charset charset) throws IOException
      压缩文件或目录到 zip 文件。
      Parameters:
      src - 源文件或目录
      zipFile - 目标 zip 文件
      charset - 文件名编码
      Throws:
      IOException - IO 异常
    • zip

      public static void zip(String srcPath, String zipPath) throws IOException
      压缩文件或目录到 zip 文件(路径字符串版本)。
      Parameters:
      srcPath - 源路径
      zipPath - 目标 zip 路径
      Throws:
      IOException - IO 异常
    • unzip

      public static void unzip(File zipFile, File outDir) throws IOException
      解压 zip 文件到目标目录(UTF-8 文件名)。
      Parameters:
      zipFile - zip 文件
      outDir - 目标目录
      Throws:
      IOException - IO 异常
    • unzip

      public static void unzip(File zipFile, File outDir, Charset charset) throws IOException
      解压 zip 文件到目标目录。
      Parameters:
      zipFile - zip 文件
      outDir - 目标目录
      charset - 文件名编码
      Throws:
      IOException - IO 异常
    • unzip

      public static void unzip(String zipPath, String outDirPath) throws IOException
      解压 zip 文件到目标目录(路径字符串版本)。
      Parameters:
      zipPath - zip 文件路径
      outDirPath - 目标目录路径
      Throws:
      IOException - IO 异常
    • zip

      public static void zip(List<File> srcList, File zipFile) throws IOException
      将多个文件/目录打包为 zip。
      Parameters:
      srcList - 源文件/目录列表
      zipFile - 目标 zip 文件
      Throws:
      IOException - IO 异常
    • zip

      public static void zip(List<File> srcList, File zipFile, Charset charset) throws IOException
      将多个文件/目录打包为 zip。
      Parameters:
      srcList - 源文件/目录列表
      zipFile - 目标 zip 文件
      charset - 文件名编码
      Throws:
      IOException - IO 异常