'using zip4j library version 1.3.2
I want to get the name of the list of files contained in a .zip file with password using zip4j library version 1.3.2.
package com.gpcoder.compress;
import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
public class UnZip4jExample {
public static final String ZIP_FILE = "C:/demo/zip4jFolderExample.zip";
public static final String DESTINATION_FOLDER = "C:/demo/outputZip4j";
public static final String PASSWORD = "yourPassword";
public static void main(String[] args) throws ZipException {
ZipFile zipFile = new ZipFile(ZIP_FILE);
if (zipFile.isEncrypted()) {
zipFile.setPassword(PASSWORD);
}
zipFile.extractAll(DESTINATION_FOLDER);
System.out.println("Done!!!");
}
}
Solution 1:[1]
In javafx using zip4j version 1.3.2
You can create a list to save your headers. In list items you can call .getFileName()
ZipFile zipFile = new ZipFile(fileZip);
if (zipFile.isEncrypted()) {
zipFile.setPassword(password);
}
List<FileHeader> fileHeaders = zipFile.getFileHeaders();
for(FileHeader fileHeader : fileHeaders) {
System.out.println(fileHeader.getFileName()); // getFileName is ok
zipFile.extractFile(fileHeader, outputFolder);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | quangdang |
