Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:12:52+00:00 2026-06-15T19:12:52+00:00

I am experiencing a strange behavior with java.util.zip.* I have a zip file and

  • 0

I am experiencing a strange behavior with java.util.zip.*

I have a zip file and upon decompressing follwing tihngs happen

ZipFile zipfile = new ZipFile(file, ZipFile.OPEN_READ);

This is exaxt error message

java.util.zip.ZipException: error in opening zip file
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.<init>(ZipFile.java:127)
at java.util.zip.ZipFile.<init>(ZipFile.java:143)
at com.basware.ExtractZip.unpack(ExtractZip.java:27)
at com.basware.ExtractZip.main(ExtractZip.java:17)

But if I use the following code it is able to open the archive without any errors

try {
     BufferedOutputStream dest = null;       
     File file = new File("File_Path");        
     FileInputStream fis = new FileInputStream(file);
     ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
     ZipEntry entry;
     while((entry = zis.getNextEntry()) != null) {
        System.out.println("Extracting: " +entry);
        int count;
        byte data[] = new byte[BUFFER];
        // write the files to the disk
        FileOutputStream fos = new 
      FileOutputStream(entry.getName());
        dest = new 
          BufferedOutputStream(fos, BUFFER);
        while ((count = zis.read(data, 0, BUFFER)) 
          != -1) {
           dest.write(data, 0, count);
        }
        dest.flush();
        dest.close();
     }
     zis.close();

Please note that files are compressed using WinZIP.

My question is as ZipFile and ZipInputStream are almost same ,why ZipFile is giving exception and why it is unable to perform decompression.

EDIT : The problem is if I zip the file using WinZip tool and then decompress it using listed program it is working fine.But, this problem is specifically coming for archives coming from external source(external source claims that they are using WinZip).On top of it, if I open the very same archive(external one) using WinZip tool it is showing and decompressing files.But this JAVA specific code(ZipFile) is not working at all.

EDIT: I am not able to figure it out why java native code is not working for my ZIP archives, but apache compress solved my problem.It is working for me as suggested by Ian Roberts.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:12:53+00:00Added an answer on June 15, 2026 at 7:12 pm

    ZipFile attempts to parse the “central directory” at the end of the zip in order to build up a data structure that allows you to access individual entries by name. ZipInputStream doesn’t, it only looks at the local header of each entry as it reads through the file from top to bottom. So it looks like your file has good entries but a corrupted central directory for some reason.

    There are a number of possibilities, for example issues with the encoding of non-ASCII characters in entry names, or if the zip has more than 64k entries. I would try the commons-compress implementation of ZipFile – even if it doesn’t work it should give you a more specific error message than the “something is wrong” that you get from java.util.zip.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm experiencing some strange behavior when using static imports of inherited static methods: com/example/util/BaseUtil.java:
I am experiencing some strange behavior with SQL Server CE 3.5 SP2. I have
I have been experiencing strange behavior with the header drawing the first time. Here
I am experiencing some strange behavior in my datagrid when I have a second
I am experiencing strange behavior using git stash, I have two branches v0 and
I am experiencing some strange behavior with Visual Studio 2010 and C++. I have
I am experiencing some very strange behavior when including a php file. I need
I'm experiencing some strange behavior for which I can't find any documented knowledge. Here's
I'm creating an application using fabric.js , and experiencing really strange behavior. I'm adding
Im experiencing strange behavior when converting String to DateTime and then again ToString(). Convert.ToDateTime(16-02-2012).ToString(MM/dd/yyyy)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.