Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Using ZipInputStream efficiently

Reply
Thread Tools

Using ZipInputStream efficiently

 
 
Chris Berg
Guest
Posts: n/a
 
      07-31-2005
Which one is best:

1:
DataInputStream dis=new DataInputStream(
new ZipInputStream(
new FileInputStream(filename));
2:
DataInputStream dis=new DataInputStream(
new ZipInputStream(
new BufferedInputStream(
new FileInputStream(filename))));
3:
DataInputStream dis=new DataInputStream(
new BufferedInputStream(
new ZipInputStream(
new FileInputStream(filename))));
4:
DataInputStream dis=new DataInputStream(
new BufferedInputStream(
new ZipInputStream(
new BufferedInputStream(
new FileInputStream(filename)))));


Chris
 
Reply With Quote
 
 
 
 
Chris Head
Guest
Posts: n/a
 
      07-31-2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Chris Berg wrote:
> Which one is best:
>
> 1:
> DataInputStream dis=new DataInputStream(
> new ZipInputStream(
> new FileInputStream(filename));
> 2:
> DataInputStream dis=new DataInputStream(
> new ZipInputStream(
> new BufferedInputStream(
> new FileInputStream(filename))));
> 3:
> DataInputStream dis=new DataInputStream(
> new BufferedInputStream(
> new ZipInputStream(
> new FileInputStream(filename))));
> 4:
> DataInputStream dis=new DataInputStream(
> new BufferedInputStream(
> new ZipInputStream(
> new BufferedInputStream(
> new FileInputStream(filename)))));
>
>
> Chris



Hi,
I'm guessing either 2 or 4. I would guess that ZipInputStream might well
issue repeated small reads in the process of doing its normal operations
(though I don't know this for sure), so those should be coalesced by
using a BufferedInputStream between it and FileInputStream. However, the
fact that you're using DataInputStream tells me that you're probably
reading small amounts at a time from the resulting unzipped stream as
well, so buffering between DIS and ZIS might also be useful so that the
Zip algorithm can work on large blocks of data at a time.

I guess the real answer is: benchmark it.

Chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)

iD8DBQFC7T4h6ZGQ8LKA8nwRAolOAJ9Qx1iTqjtgJcq4L2gWAI RvEQ4ueQCfXYca
0oGAnFjxwg9YN2adjZrs1+8=
=GQP8
-----END PGP SIGNATURE-----
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ZipInputStream bug Dan Hoey Java 2 01-29-2010 06:32 AM
Numarray - Using Integers Efficiently for Boolean Values andrewfelch@gmail.com Python 0 02-16-2006 06:19 PM
efficiently using .net Tracing =?Utf-8?B?ZGVlcHVrdXR0eQ==?= ASP .Net 2 10-03-2005 02:10 PM
Is this a ZipInputStream Bug? License Manager Java 2 08-10-2004 03:30 AM
So just how do you filter large numbers of netblocks efficiently? Jeff Cisco 4 06-10-2004 07:12 PM



Advertisments