wood burning stoves 2.0*
The moose likes Java in General and the fly likes Problem creating the zip file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Problem creating the zip file " Watch "Problem creating the zip file " New topic

Problem creating the zip file

Justin Howard
Ranch Hand

Joined: Feb 19, 2009
Posts: 162
Hi All,

This is the code I am using to create a zip file with a pdf file.
The same code works fine when I create a zip file with a doc file.
When I open the pdf in the zip file, it says it is corrupted or damaged and cannot be opened.

Rob Spoor

Joined: Oct 27, 2005
Posts: 19649

What is the return value of fis.read(buf,0,buf.length)? Just because you try to read it all at once, don't assume that will succeed. You should always read data in a loop, and use the return value to determine what to write:

How To Ask Questions How To Answer Questions
I agree. Here's the link: http://aspose.com/file-tools
subject: Problem creating the zip file
Similar Threads
zip files without path info...
Issue with Download using ZipOutputStream
Windows does not recognize Java created ZIP
Java Error While appending to Zip File
how to put two different folders(which is in different location) into one zip entry