I have chased this up w/ groups.google and then w/ the bug parade at Sun.
It seems to be an unresolved issue.
I was wondering if comeone could take a quick look at the following method
and tell me (bugs aside) whether there is anything wrong with this.
private File uncompress(File f) throws Exception {
File toReturn = null;
try {
toReturn = new File("" + f.getName() + ".uncomp");
ZipInputStream zin = new ZipInputStream(new FileInputStream(f));
FileOutputStream out = new FileOutputStream(toReturn);
ZipEntry e;
byte[] buffer = new byte[512];
int len = 0;
while((e = zin.getNextEntry()) != null) {
System.out.println("looping, zip entry: " + e.getName());
while((len=zin.read(buffer)) != -1) {
System.out.println("" + len);
out.write(buffer, 0, len);
}
zin.closeEntry();
}
zin.close();
out.close();
} catch( Exception exc ) {
exc.printStackTrace();
throw new Exception("Exception occurred in method uncompress.");
}
return toReturn;
}
i can't see anything wrong with this, and it works fine for me (win2k,
java1.4.2). I tried running it on "src.zip" which is distributed with the
SDK and it had no troubles. What exactly is the stack trace? could the error
be from a corrupt zip file?
asjf
"Andrew Tucker" <andrew...@optusnet.com.au> wrote in message
news:3f6e...@news.comindico.com.au...
>ZipInputStream zin = new ZipInputStream(new FileInputStream(f));
Try using ZipFile rather than ZipInputStream.
See http://mindprod.com/jgloss/zip.html for why
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
I thought perhaps you might be interested in the error msg and stack trace
for your error messages page. This one certainly had me stumped for quite a
while. Thankyou also for all your help directly and indirectly via 'the
glossary'. I have also included the code used to generate the zip files.
Forgive me mailing it here, i am currently also a victim of the 'virus
storm'.
java.io.EOFException: Unexpected end of ZLIB input stream
at java.util.zip.InflaterInputStream.fill(Unknown Source)
at java.util.zip.InflaterInputStream.read(Unknown Source)
at java.util.zip.ZipInputStream.read(Unknown Source)
at java.io.FilterInputStream.read(Unknown Source)
at ClientSide.uncompress(ClientSide.java:76)
at ClientSide.<init>(ClientSide.java:42)
at ClientSide.main(ClientSide.java:18)
private File compress(File f) throws Exception {
int entryCount = 0;
File toReturn = null;
try {
toReturn = new File(f.getName() + ".comp");
ZipOutputStream zos = new ZipOutputStream(new
FileOutputStream(toReturn));
FileInputStream in = new FileInputStream(f);
ZipEntry ze;
byte[] buffer = new byte[512];
while(in.read(buffer) != EOF) {
ze = new ZipEntry("" + ++entryCount);
// System.out.println("Going around again. entryCount: " +
entryCount);
zos.putNextEntry(ze);
zos.write(buffer);
}
return toReturn;
} catch( Exception exc ) {
exc.printStackTrace();
throw new Exception("Exception occurred in method send.");
}
}
cheers, Andrew.
"Roedy Green" <ro...@mindprod.com> wrote in message
news:lmiumvkac5stnqv7l...@4ax.com...
"Roedy Green" <ro...@mindprod.com> wrote in message
news:lmiumvkac5stnqv7l...@4ax.com...
>When reading elements of the zipfile, entry.getSize() always returns -1. I
>am therefore getting a negative array size exception!
read http://mindprod.com/jgloss/zip.html to explain why.
"Roedy Green" <ro...@seewebsite.com> wrote in message
news:tn41nv4tp1618m822...@4ax.com...