Java Code Examples for net.lingala.zip4j.ZipFile#getFileHeaders()
The following examples show how to use
net.lingala.zip4j.ZipFile#getFileHeaders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZipOutputStreamIT.java From zip4j with Apache License 2.0 | 6 votes |
private void verifyEntries() throws ZipException { ZipFile zipFile = new ZipFile(generatedZipFile); for (FileHeader fileHeader : zipFile.getFileHeaders()) { byte[] generalPurposeBytes = fileHeader.getGeneralPurposeFlag(); assertThat(BitUtils.isBitSet(generalPurposeBytes[0], 3)).isTrue(); if (fileHeader.isEncrypted() && fileHeader.getEncryptionMethod().equals(EncryptionMethod.AES)) { if (fileHeader.getAesExtraDataRecord().getAesVersion().equals(AesVersion.TWO)) { assertThat(fileHeader.getCrc()).isZero(); } else if (fileHeader.getCompressedSize() > 0) { assertThat(fileHeader.getCrc()).isNotZero(); } } } }
Example 2
Source File: ZipOutputStreamIT.java From zip4j with Apache License 2.0 | 5 votes |
private void verifyFileEntryComment(String commentPrefix, Charset charset) throws IOException { ZipFile zipFile = initializeZipFileWithCharset(charset); List<FileHeader> fileHeaders = zipFile.getFileHeaders(); for (int i = 0; i < fileHeaders.size(); i++) { FileHeader fileHeader = fileHeaders.get(i); if (i == 0) { assertThat(fileHeader.getFileComment()).isEqualTo(commentPrefix + i); } else { assertThat(fileHeader.getFileComment()).isNull(); } } }
Example 3
Source File: Main2.java From apkfile with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { ZipFile zipFile = new ZipFile(args[0]); System.out.println("Is valid " + zipFile.isValidZipFile()); for (Object header : zipFile.getFileHeaders()) { System.out.println("Found header: " + ((FileHeader) header).getFileName()); } System.out.println("Getting stupid entry: " + zipFile.getFileHeader("asdflkasdjflskjdderpy")); }
Example 4
Source File: ApkFile.java From apkfile with Apache License 2.0 | 5 votes |
private static Map<String, FileHeader> buildEntryNameToEntry(ZipFile zipFile) throws ZipException { Map<String, FileHeader> entryNameToEntry = new HashMap<>(); for (FileHeader fileHeader : zipFile.getFileHeaders()) { entryNameToEntry.put(fileHeader.getFileName(), fileHeader); } return entryNameToEntry; }
Example 5
Source File: HeaderVerifier.java From zip4j with Apache License 2.0 | 4 votes |
public static void verifyZipFileDoesNotContainFolders(ZipFile zipFile, Collection<String> folderNames) throws IOException { for (FileHeader fileHeader : zipFile.getFileHeaders()) { folderNames.forEach(e -> assertThat(fileHeader.getFileName().startsWith(e)).isFalse()); } }