JDK-4113731 : ZipEntries retrieved through ZipInputStream return no values
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util
  • Affected Version: 1.1.5,6
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_9,windows_nt
  • CPU: x86,sparc
  • Submitted: 1998-02-20
  • Updated: 1998-07-20
  • Resolved: 1998-07-20
Related Reports
Duplicate :  
Description
A ZipEntry that was being retrieved through ZipInputStream.getNextEntry()
returns -1 when getCompressedSize() and getSize() are being asked.
I have tried this by creating an archive of an directory using jar -cvMf ...

Testcase:

import java.io.*;
import java.util.*;
import java.util.zip.*;

public class test extends Object
{
	static public void main(String args[]) throws Exception {
		ZipInputStream	inzip = null;
		ZipEntry	entry = null;

		inzip = new ZipInputStream(new FileInputStream("somearchive"));
		while (true) {
			entry = inzip.getNextEntry();
			if (entry.getName().equals("somefile")) {
				System.out.println(" Name: " +
					entry.getName());
				System.out.println("CSize: " +
					entry.getCompressedSize());
				System.out.println("USize: " +
					entry.getSize());
				break;
			}
		}
	}
}

Comments
EVALUATION Not a bug. ZipInputStream can only read zip entries sequentially, and if the data of a certain entry is compressed, its size information is stored at the end of the actual data, that is why the size inforamtion in the zip entry is invalid. ###@###.### 1998-07-20
20-07-1998