[jcifs] Ramdom Access File (Zip file partial read using CIFS)

Michael B Allen ioplex at gmail.com
Tue Jul 14 12:25:56 MDT 2009


On Tue, Jul 14, 2009 at 7:07 AM, Giampaolo
Tomassoni<Giampaolo at tomassoni.biz> wrote:
>> -----Original Message-----
>> From: jcifs-bounces at lists.samba.org [mailto:jcifs-
>> bounces at lists.samba.org] On Behalf Of pedrofaundezgon at terra.es
>> Sent: Tuesday, July 14, 2009 11:24 AM
>> To: jcifs at lists.samba.org
>> Subject: [jcifs] Ramdom Access File (Zip file partial read using CIFS)
>>
>> I want to access the contents of a Zip file from a Java program.
>> I know java.util.zip.ZipFile can only access local files.
>> And I also know the default API exposed by jcifs is only java.io.
>> InputStream API
>> Is there an easy way to read a huge ZipFile over the network
>> extracting only the file I am interested in the most efficient way
>> possible?
>> Is there a way to have jcifs expose a random access file interface
>> (just like local file) and a way to have ZipFile consume it?
>
> First, jcifs seems also define a jcifs.smb.SmbRandomAccessFile class.
>
> However, I think you wouldn't need it. I would instead check if:
>
> 1) java.util.zip.ZipInputStream uses skip() on the InputStream passed in its constructor in order to position itself in the zip file;
>
> 2) the skip() method in jcifs.smb.SmbFileInputStream effectively skips bytes instead of transferring them.
>
> If both these checks are true, you may directly pass an SmbFileInputStream to the ZipInputStream constructor and enumerate the zip entries: it shouldn't trigger the transfer of the complete zip file but only of the parts you need...

SmbFileInputStream.skip does in fact just move the file pointer and
does not actually read the data. So I would try passing an
SmbFileInputStream to the ZipInputStream constructor and then use a
sufficiently high log level to see if JCIFS is actually reading
through the entire Zip file.

Mike

-- 
Michael B Allen
Java Active Directory Integration
http://www.ioplex.com/


More information about the jcifs mailing list