前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Java工具集-ZIP解压工具

Java工具集-ZIP解压工具

作者头像
cwl_java
发布2020-01-14 14:58:14
2.2K0
发布2020-01-14 14:58:14
举报
文章被收录于专栏:cwl_Javacwl_Java
  1. 添加依赖
代码语言:javascript
复制
		<!--ZIP工具-->
        <dependency>
            <groupId>net.lingala.zip4j</groupId>
            <artifactId>zip4j</artifactId>
            <version>1.3.1</version>
        </dependency>
  1. 代码示例
代码语言:javascript
复制
package com.simple.util.base.extend.zip;

import net.lingala.zip4j.core.ZipFile;

/**
 * @program: simple_tools
 * @description: ZIP解壓工具
 * @author: ChenWenLong
 * @create: 2020-01-07 16:52
 **/
public class ZipUtil {

    /**
     * 功能描述:
     * 〈解压zip文件〉
     *
     * @params : [zipFilePath, targetPath]
     * @return : void
     * @author : cwl
     * @date : 2020/1/7 16:52
     */
    public static void unzip(String zipFilePath,String targetPath) throws Exception{
        ZipFile zipFile = new ZipFile(zipFilePath);
        zipFile.extractAll(targetPath);
    }

    /**
     * 功能描述:
     * 〈解压zip文件(带密码)〉
     *
     * @params : [zipFilePath, password, targetPath]
     * @return : void
     * @author : cwl
     * @date : 2020/1/7 16:54
     */
    public static void unzip(String zipFilePath,String password,String targetPath) throws Exception{
        ZipFile zipFile = new ZipFile(zipFilePath);
        if (zipFile.isEncrypted()) {
            zipFile.setPassword(password);
        }
        zipFile.extractAll(targetPath);
    }

}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档