List of usage examples for org.apache.commons.compress.archivers.tar TarArchiveEntry hashCode
public int hashCode()
From source file:com.amaze.filemanager.filesystem.compressed.extractcontents.helpers.TarExtractor.java
@Override protected void extractWithFilter(@NonNull Filter filter) throws IOException { long totalBytes = 0; List<TarArchiveEntry> archiveEntries = new ArrayList<>(); TarArchiveInputStream inputStream = new TarArchiveInputStream(new FileInputStream(filePath)); TarArchiveEntry tarArchiveEntry;//from w w w . j a va 2s . com while ((tarArchiveEntry = inputStream.getNextTarEntry()) != null) { if (CompressedHelper.isEntryPathValid(tarArchiveEntry.getName())) { if (filter.shouldExtract(tarArchiveEntry.getName(), tarArchiveEntry.isDirectory())) { archiveEntries.add(tarArchiveEntry); totalBytes += tarArchiveEntry.getSize(); } } else { invalidArchiveEntries.add(tarArchiveEntry.getName()); } } listener.onStart(totalBytes, archiveEntries.get(0).getName()); inputStream.close(); inputStream = new TarArchiveInputStream(new FileInputStream(filePath)); for (TarArchiveEntry entry : archiveEntries) { if (!listener.isCancelled()) { listener.onUpdate(entry.getName()); //TAR is sequential, you need to walk all the way to the file you want while (entry.hashCode() != inputStream.getNextTarEntry().hashCode()) ; extractEntry(context, inputStream, entry, outputPath); } } inputStream.close(); listener.onFinish(); }
From source file:com.amaze.filemanager.filesystem.compressed.extractcontents.helpers.GzipExtractor.java
@Override protected void extractWithFilter(@NonNull Filter filter) throws IOException { long totalBytes = 0; ArrayList<TarArchiveEntry> archiveEntries = new ArrayList<>(); TarArchiveInputStream inputStream = new TarArchiveInputStream( new GzipCompressorInputStream(new FileInputStream(filePath))); TarArchiveEntry tarArchiveEntry;/*from w ww .j a v a2 s. c om*/ while ((tarArchiveEntry = inputStream.getNextTarEntry()) != null) { if (CompressedHelper.isEntryPathValid(tarArchiveEntry.getName())) { if (filter.shouldExtract(tarArchiveEntry.getName(), tarArchiveEntry.isDirectory())) { archiveEntries.add(tarArchiveEntry); totalBytes += tarArchiveEntry.getSize(); } } else { invalidArchiveEntries.add(tarArchiveEntry.getName()); } } listener.onStart(totalBytes, archiveEntries.get(0).getName()); inputStream.close(); inputStream = new TarArchiveInputStream(new GzipCompressorInputStream(new FileInputStream(filePath))); for (TarArchiveEntry entry : archiveEntries) { if (!listener.isCancelled()) { listener.onUpdate(entry.getName()); //TAR is sequential, you need to walk all the way to the file you want while (entry.hashCode() != inputStream.getNextTarEntry().hashCode()) ; extractEntry(context, inputStream, entry, outputPath); } } inputStream.close(); listener.onFinish(); }