java.io.EOFException: Unexpected end of ZLIB input stream

Discussion in 'Java' started by ilya, Dec 22, 2010.

  1. ilya

    ilya Guest

    ZipInputStream in = new ZipInputStream(new FileInputStream(file));
    in.getNextEntry();
    OutputStream out = new FileOutputStream(outFile);
    int mayRead = in.available();
    byte[] buf = new byte[BUFFER_SIZE];
    int len;
    while ((len = in.read(buf, 0, Math.min(mayRead, BUFFER_SIZE)))
    > 0) {

    out.write(buf, 0, len);
    }
    in.closeEntry();
    out.close();
    in.close();

    BUFFER_SIZE = 1024;

    To unpack the zipped file I use the above method. On windows all works
    fine. But on MAC I got the following error:
    java.io.EOFException: Unexpected end of ZLIB input stream
    at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:
    223)
    at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:
    141)
    at java.util.zip.ZipInputStream.read(ZipInputStream.java:154)
    at java.io.FilterInputStream.read(FilterInputStream.java:90)

    How can I solve it?
     
    ilya, Dec 22, 2010
    #1
    1. Advertising

  2. ilya

    Arne Vajhøj Guest

    On 22-12-2010 05:21, ilya wrote:
    > ZipInputStream in = new ZipInputStream(new FileInputStream(file));
    > in.getNextEntry();
    > OutputStream out = new FileOutputStream(outFile);
    > int mayRead = in.available();
    > byte[] buf = new byte[BUFFER_SIZE];
    > int len;
    > while ((len = in.read(buf, 0, Math.min(mayRead, BUFFER_SIZE)))
    >> 0) {

    > out.write(buf, 0, len);
    > }
    > in.closeEntry();
    > out.close();
    > in.close();
    >
    > BUFFER_SIZE = 1024;
    >
    > To unpack the zipped file I use the above method. On windows all works
    > fine. But on MAC I got the following error:
    > java.io.EOFException: Unexpected end of ZLIB input stream
    > at java.util.zip.InflaterInputStream.fill(InflaterInputStream.java:
    > 223)
    > at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:
    > 141)
    > at java.util.zip.ZipInputStream.read(ZipInputStream.java:154)
    > at java.io.FilterInputStream.read(FilterInputStream.java:90)
    >
    > How can I solve it?


    The .available() method is not very reliable - I would avoid that.

    Just read up to BUFFER_SIZE.

    Have you verified that the zip file is actually readable on
    MacOS X. The exception could be caused by file corruption - like
    transferring the file as text instead of binary.

    Arne
     
    Arne Vajhøj, Dec 25, 2010
    #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. Andrew Tucker

    Zip Hassles, EOFException.

    Andrew Tucker, Sep 22, 2003, in forum: Java
    Replies:
    6
    Views:
    3,613
    Andrew Tucker
    Sep 24, 2003
  2. David Baer

    EOFException at ObjectInputStream

    David Baer, Feb 25, 2004, in forum: Java
    Replies:
    2
    Views:
    15,243
    David Baer
    Feb 26, 2004
  3. Matthew Brett
    Replies:
    4
    Views:
    1,187
    Matthew Brett
    May 9, 2010
  4. Daniel Berger
    Replies:
    5
    Views:
    270
    Roger Pack
    Jun 21, 2009
  5. Nicholas Wieland

    Most simple usage of zlib or pr-zlib

    Nicholas Wieland, Mar 9, 2011, in forum: Ruby
    Replies:
    4
    Views:
    354
    Jeremy Bopp
    Mar 10, 2011
Loading...

Share This Page