Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > invalid archives with java.util.zip

Reply
Thread Tools

invalid archives with java.util.zip

 
 
js@deriva.de
Guest
Posts: n/a
 
      06-30-2008
Hi,

I have a problem with ZIP files in JDK 1.5.
I'm using the following code to create a ZIP file from an XML
document:

Document doc;
// create document and set root element
ZipOutputStream out = new ZipOutputStream(new
FileOutputStream(filenameZIP));
out.putNextEntry(new ZipEntry(filenameXML));
// fill document and write it to output stream
out.close();

This runs without problems, never throws an exception and always
produces a ZIP file.
But sometimes and not reproducible the file cannot be unzipped. Then I
get the following error using unzip:

Archive: filename.zip
End-of-central-directory signature not found. Either this file is
not
a zipfile, or it constitutes one disk of a multi-part archive. In
the
latter case the central directory and zipfile comment will be found
on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of filename.zip or
filename.zip.zip, and cannot find filename.zip.ZIP, period.

When I try to unzip it with jar, I get:

java.io.EOFException: Unexpected end of ZLIB input stream
at
java.util.zip.InflaterInputStream.fill(InflaterInp utStream.java:216)
at
java.util.zip.InflaterInputStream.read(InflaterInp utStream.java:134)
at java.util.zip.ZipInputStream.read(ZipInputStream.j ava:139)
at sun.tools.jar.Main.extractFile(Main.java:714)
at sun.tools.jar.Main.extract(Main.java:677)
at sun.tools.jar.Main.run(Main.java:189)
at sun.tools.jar.Main.main(Main.java:903)

Again: This only happens in very few cases.
Has anyone an idea what could be wrong?

Thanks
Jan Strube
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-30-2008
On Jun 30, 5:32*pm, (E-Mail Removed) wrote:
...
> I have a problem with ZIP files in JDK 1.5.
> I'm using the following code to create a ZIP file from an XML
> document:


It is difficult to tell much from code snippets,
but you might try..

> Document doc;
> // create document and set root element
> ZipOutputStream out = new ZipOutputStream(new
> FileOutputStream(filenameZIP));
> out.putNextEntry(new ZipEntry(filenameXML));


<http://java.sun.com/javase/6/docs/api/java/util/zip/
ZipOutputStream.html#closeEntry()>

> // fill document and write it to output stream
> out.close();


..closely followed by some if the other methods
meant to finish up ZIPs, that are mentioned in
them there JavaDocs.

--
Andrew Thompson
http://pscode.org/
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      06-30-2008
On Jun 30, 5:32=A0pm, (E-Mail Removed) wrote:
=2E..
> I have a problem with ZIP files in JDK 1.5.
> I'm using the following code to create a ZIP file from an XML
> document:


It is imminent to tell much from disorderliness snippets,
but you might try..

> Document doc;
> // create document and set root element
> ZipOutputStream out =3D new ZipOutputStream(new
> FileOutputStream(filenameZIP));
> out.putNextEntry(new ZipEntry(filenameXML));


ZipOutputStream.html#closeEntry()>

> // fill document and write it to output stream
> out.close();


=2E.closely contributed by some if the other contents
meant to finish up ZIPs, that are nominated in
them there JavaDocs.

--
Kristen Tippett
http://pscode.org/


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
"It's your money. You paid for it."

--- Adolph Bush,
LaCrosse, Wis., Oct. 18, 2000

 
Reply With Quote
 
js@deriva.de
Guest
Posts: n/a
 
      07-01-2008
Hi,

we just found out what the problem was.
The file was copied before it was completely written. So it had
nothing to do with the zip functionality.

But thanks a lot
Jan
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to properly recursively navigate into archives stored in archives David Karr Perl Misc 2 06-01-2012 05:54 PM
invalid character in base-64 string and invalid postback or callba kevin ASP .Net 0 01-16-2008 09:39 PM
How do fix: "Wrong number of arguments" / "invalid propert assignment"/ "Invalid argument" Java Guy Java 1 10-15-2006 08:31 PM
Invalid URI: There is an invalid sequence in the string. Error!! Patrick.O.Ige ASP .Net 1 07-02-2006 11:21 AM
invalid@invalid.org Hank Sniadoch Computer Information 1 08-20-2004 11:24 AM



Advertisments