Reputation: 448
I want to return boolean to check if my zip file is compressed . Will be an advantage if i can also get what Compression method has been used. For now I am just checking is it is Encrypted and is valid zip. Please help if it is possible using zip4j library.
public static boolean isPackageCompressed(String path) throws ZipException{
boolean isPackageCompressed = false;
ZipFile zipFile = new ZipFile(path);
System.out.println(zipFile.isEncrypted());
System.out.println(zipFile.isValidZipFile());
// TODO. There is no method like zipFile.getCompressionMethod() .
return isPackageCompressed;
}
public static void main(String[] args) {
try {
isPackageCompressed("D:\\some.ZIP");
} catch (ZipException e) {
e.printStackTrace();
}
}
Upvotes: 1
Views: 1450
Reputation: 84
Check this out may be helpful (Not the complete answer )
ZipParameters zp = new ZipParameters();
zp.setFileNameInZip("sample.zip");
System.out.println(zp.getCompressionMethod());
System.out.println(Zip4jConstants.COMP_DEFLATE);
OutPut:
8
8
Upvotes: 1