David M. Lloyd wrote:
-snip-
The only reasonably accurate way to get the directory is to
read the *end* of the file first, which generally means that InputStream
is not an option to get this data. The only real option is to use a
random-access file method (FileChannel or RandomAccessFile) to get at
this data. This means that if you have an InputStream (which is what
you can generally get out of VFS), you need to create a temp file and
slurp the data into it before you can index it.
I realize that this is a full iteration of the zip file, *however* it
means that once you do this, you have instant access to any zip entry
from that point on
If the source is local vfs file, we should be able to pass that directly
as a RandomAccessFile. If we do need to copy it, we can use an optimized
(potentially os-centric) copy mechanism. If the url is remote (say on a
DAV source), then your proposed design would still be more efficient,
because you don't have to do any decoding work, you just use an optimial
buffer size, and chunk the file as fast as you can.
--
Jason T. Greene
JBoss, a division of Red Hat