Is there some kind of file size limitation to Java's zip package?

Trying to use Java zip package to zip a huge file (7.5 Gb) and it takes a full 9 minutes to zip it up but at the end when I load the zip with WinZip it reprots the file size as 3.5 Gb (uncompressed). What happened to the other half? If I try to extract it, winzip runs into an error.

However here's what is interesting, when I use WinZip to zip the file, it also takes the same time - 9 minutes, and produces a zip file of about the same size (730 megs) but it has no problem reporting the full size as 7.5 Gb when opened.

So what's the deal? It is as if Java's zip library went through the whole thing and compressed it but didnt put the right header information so WinZip doesn't know how to extract it?

my code atatched:

publicvoid run(){

ZipOutputStream out =null;

try{

out =new ZipOutputStream(new FileOutputStream(zipFilename));

for (int i=0; i<filenames.length; i++){

File f =new File(filenames[i]);

byte[] buffer =newbyte[1024 * 1024 * 100];

FileInputStream in =new FileInputStream(f);

out.putNextEntry(new ZipEntry(f.getName()));

int read;

while ( (read = in.read(buffer)) > 0){

out.write(buffer, 0, read);

}

out.closeEntry();

in.close();

}

}catch (Throwable e){

System.out.println("Error: "+e.getMessage());

}finally{

try{ out.close();}catch (Exception e){}

}

}

[2564 byte] By [SpamFiltera] at [2007-10-3 6:12:21]
# 1

Of course java zip isn't winzip.

You might have found a bug.

You should try reducing your original file to the point where the output is slightly less than 2 gigs.

If that works then increase it to just over 2 gigs (output) and see if that fails.

If that doesn't work then try reducing the input file to just under 2 gigs, see if it works, and if it does then increase it to just over.

jschella at 2007-7-15 0:56:07 > top of Java-index,Java Essentials,Java Programming...
# 2

Note that the ZIP package API has a reference "Info-ZIP Application Note 970311 - a detailed description of the Info-ZIP format upon which the java.util.zip classes are based."

This states the file size fields are 4-bytes. Newer versions of various compressions programs have expanded these limits.

http://www.google.com/search?q=zip+size+limit

ChuckBinga at 2007-7-15 0:56:07 > top of Java-index,Java Essentials,Java Programming...
# 3
If your just compressing one file you could try GZipOutputstream instead.
Caffeine0001a at 2007-7-15 0:56:07 > top of Java-index,Java Essentials,Java Programming...