package com.hgq; import com.hgq.util.RarUtil; import com.hgq.util.ZipUtil; import java.io.File; import java.io.IOException; /** * TODO 类的作用信息 * * @author huguangquan * @date 22-9-16 016 */ public class Test { public static void main(String[] args) { // 压缩文件存放目录 String compressPath = "D:\\compress_file\\"; // 解压缩文件存放目录 String decompressPath = "D:\\decompress_file\\"; //unzip(compressPath, decompressPath); unrar(compressPath, decompressPath); } private static void unzip(String compressPath, String decompressPath) { String zipFile = compressPath + "\\" + "test.zip"; try { ZipUtil.unZip(new File(zipFile), decompressPath); System.out.println("zip文件解压缩完成"); } catch (IOException e) { e.printStackTrace(); } } private static void unrar(String compressPath, String decompressPath) { String rarFile = compressPath + "\\" + "ma1.rar"; // 测试Rar5版本压缩文件 RarUtil.unRar(rarFile, decompressPath); System.out.println("rar 文件解压缩完成"); } }