Search in sources :

Example 1 with BoundedInputStream

use of com.mucommander.commons.io.BoundedInputStream in project mucommander by mucommander.

the class ArArchiveFile method getEntryInputStream.

@Override
public InputStream getEntryInputStream(ArchiveEntry entry, ArchiveEntryIterator entryIterator) throws IOException, UnsupportedFileOperationException {
    InputStream in = getInputStream();
    ArchiveEntryIterator iterator = new ArArchiveEntryIterator(in);
    ArchiveEntry currentEntry;
    while ((currentEntry = iterator.nextEntry()) != null) {
        if (currentEntry.getName().equals(entry.getName())) {
            LOGGER.trace("found entry {}", entry.getName());
            return new BoundedInputStream(in, entry.getSize(), false);
        }
    }
    // Entry not found, should not normally happen
    LOGGER.info("Warning: entry not found, throwing IOException");
    throw new IOException();
}
Also used : BoundedInputStream(com.mucommander.commons.io.BoundedInputStream) InputStream(java.io.InputStream) BoundedInputStream(com.mucommander.commons.io.BoundedInputStream) ArchiveEntry(com.mucommander.commons.file.archive.ArchiveEntry) ArchiveEntryIterator(com.mucommander.commons.file.archive.ArchiveEntryIterator) IOException(java.io.IOException)

Aggregations

ArchiveEntry (com.mucommander.commons.file.archive.ArchiveEntry)1 ArchiveEntryIterator (com.mucommander.commons.file.archive.ArchiveEntryIterator)1 BoundedInputStream (com.mucommander.commons.io.BoundedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1