public static void main(String[] args) {
String zipFilePath = "文件路径\\文件名"; //解压的文件目录
String extractPath = "文件路径"; //解压后的文件保存目录
String password = "密码";
unzipEncryptedZip(zipFilePath, extractPath, password);
}
public static void unzipEncryptedZip(String zipFilePath, String extractPath, String password) {
try {
String command = "7z x \"" + zipFilePath + "\" -o\"" + extractPath + "\" -p" + password;
Process process = Runtime.getRuntime().exec(command);
process.waitFor();
System.out.println("解压完成!");
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
只需要引用一个即可
import java.io.IOException;