Using ZipInputStream efficiently

Discussion in 'Java' started by Chris Berg, Jul 31, 2005.

  1. Chris Berg

    Chris Berg Guest

    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
     
    Chris Berg, Jul 31, 2005
    #1
    1. Advertising

  2. Chris Berg

    Chris Head Guest

    -----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)

    iD8DBQFC7T4h6ZGQ8LKA8nwRAolOAJ9Qx1iTqjtgJcq4L2gWAIRvEQ4ueQCfXYca
    0oGAnFjxwg9YN2adjZrs1+8=
    =GQP8
    -----END PGP SIGNATURE-----
     
    Chris Head, Jul 31, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ibeetb

    Programming Excel Efficiently

    ibeetb, Dec 15, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    407
    Alvin Bruney
    Dec 16, 2003
  2. =?Utf-8?B?ZGVlcHVrdXR0eQ==?=

    efficiently using .net Tracing

    =?Utf-8?B?ZGVlcHVrdXR0eQ==?=, Oct 3, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    356
    =?Utf-8?B?VmVua2F0X0tM?=
    Oct 3, 2005
  3. License Manager

    Is this a ZipInputStream Bug?

    License Manager, Aug 10, 2004, in forum: Java
    Replies:
    2
    Views:
    593
    License Manager
    Aug 10, 2004
  4. Replies:
    0
    Views:
    275
  5. Dan Hoey

    ZipInputStream bug

    Dan Hoey, Jan 27, 2010, in forum: Java
    Replies:
    2
    Views:
    430
    Roedy Green
    Jan 29, 2010
Loading...

Share This Page