Java Code Examples for org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry#getSize()
The following examples show how to use
org.apache.commons.compress.archivers.sevenz.SevenZArchiveEntry#getSize() .
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: SevenZParser.java From bubble with MIT License | 6 votes |
@Override public void parse(File file) throws IOException { mEntries = new ArrayList<>(); SevenZFile sevenZFile = new SevenZFile(file); SevenZArchiveEntry entry = sevenZFile.getNextEntry(); while (entry != null) { if (entry.isDirectory()) { continue; } if (Utils.isImage(entry.getName())) { byte[] content = new byte[(int)entry.getSize()]; sevenZFile.read(content); mEntries.add(new SevenZEntry(entry, content)); } entry = sevenZFile.getNextEntry(); } Collections.sort(mEntries, new NaturalOrderComparator() { @Override public String stringValue(Object o) { return ((SevenZEntry) o).entry.getName(); } }); }
Example 2
Source File: ZipReader.java From kkFileView with Apache License 2.0 | 5 votes |
@Override public void run() { try { SevenZFile sevenZFile = new SevenZFile(new File(filePath)); SevenZArchiveEntry entry = sevenZFile.getNextEntry(); while (entry != null) { if (entry.isDirectory()) { entry = sevenZFile.getNextEntry(); continue; } String childName = "default_file"; SevenZArchiveEntry entry1; for (Map<String, SevenZArchiveEntry> entryMap : entriesToBeExtracted) { childName = entryMap.keySet().iterator().next(); entry1 = entryMap.values().iterator().next(); if (entry.getName().equals(entry1.getName())) { break; } } FileOutputStream out = new FileOutputStream(fileDir + childName); byte[] content = new byte[(int) entry.getSize()]; sevenZFile.read(content, 0, content.length); out.write(content); out.close(); entry = sevenZFile.getNextEntry(); } sevenZFile.close(); } catch (IOException e) { e.printStackTrace(); } if (new File(filePath).exists()) { new File(filePath).delete(); } }