Search in sources :

Example 1 with FilterRandomAccessInputStream

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

the class IsoArchiveFile method getEntryInputStream.

@Override
public InputStream getEntryInputStream(ArchiveEntry entry, ArchiveEntryIterator entryIterator) throws IOException, UnsupportedFileOperationException {
    // Cast the entry before creating the stream, in case it fails
    IsoArchiveEntry isoEntry = (IsoArchiveEntry) entry;
    RandomAccessInputStream rais;
    // If a IsoEntryIterator is specified, reuse the iterator's stream
    if (entryIterator != null && entryIterator instanceof IsoEntryIterator) {
        // Override close() as a no-op so that the stream is re-used from one entry to another -- the stream will
        // be closed when the iterator is closed.
        rais = new FilterRandomAccessInputStream(((IsoEntryIterator) entryIterator).getRandomAccessInputStream()) {

            @Override
            public void close() throws IOException {
            // No-op
            }
        };
    } else {
        rais = getRandomAccessInputStream();
    }
    return new IsoEntryInputStream(rais, isoEntry);
}
Also used : FilterRandomAccessInputStream(com.mucommander.commons.io.FilterRandomAccessInputStream) FilterRandomAccessInputStream(com.mucommander.commons.io.FilterRandomAccessInputStream) RandomAccessInputStream(com.mucommander.commons.io.RandomAccessInputStream) IOException(java.io.IOException)

Aggregations

FilterRandomAccessInputStream (com.mucommander.commons.io.FilterRandomAccessInputStream)1 RandomAccessInputStream (com.mucommander.commons.io.RandomAccessInputStream)1 IOException (java.io.IOException)1