public static SeekableByteChannel byteChannelForEntry(BundleEntry entry) throws IOException {
        SeekableByteChannel chan;

        // check if the entry is larger than 128 MiB
        long size = entry.size();
        if (size > 1 << 27) {
            // copy entry to temporary file
            Path tmpFile = Files.createTempFile("disunity", null);
            Files.copy(entry.inputStream(), tmpFile, REPLACE_EXISTING);
            chan = Files.newByteChannel(tmpFile, READ, DELETE_ON_CLOSE);
        } else {
            // copy entry to memory
            ByteBuffer bb = ByteBuffer.allocateDirect((int) size);
            IOUtils.copy(entry.inputStream(), new ByteBufferOutputStream(bb));
            bb.flip();
            chan = new ByteBufferChannel(bb);
        }

        return chan;
    }
Asset bundle file utility class.

@author Nico Bergemann <barracuda415 at yahoo.de>
disunity-core/src/main/java/info/ata4/junity/bundle/BundleUtils.java