• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Problem Creating ZIP File

 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings to you, dear Reader,
I am using java 1.6.0_30 on Windows2000
I am using the classes in the java.util.zip package to create a ZIP archive that contains all the files in a single folder.
The folder contains over 2,500 files where each file is a PDF file.
Average size of the PDF files is 20 kilobytes and there are 9 (nine) gigabytes of free space on the computer's hard disk.
The problem is that the ZIP archive does not contain all the files in the folder.
I am not getting any error messages.
Here is the code:

Note that I have run the above code when the folder contains only 50 files and all the files where added to the ZIP archive.

Thanks,
Avi.
 
Sheriff
Posts: 28395
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, I would suggest you should fix your file-copying logic so it copies the whole file and nothing but the file. However regardless of the fact that you're putting extra garbage into the archive, that isn't causing the problem you describe.

Have you considered doing any debugging? Like watching the code and seeing what it actually does? Or have you considered looking at the data to see which files are being written and which aren't? Just telling us there's a problem isn't very helpful. What would be helpful would be information of that type.
 
Avi Abrami
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Paul,
Thank you for your reply. In it you write:


I would suggest you should fix your file-copying logic so it copies the whole file and nothing but the file


I would greatly appreciate it if you would show me code to achieve this.
You also wrote:


have you considered looking at the data to see which files are being written and which aren't


I have already done this.
As I wrote in my original post: The code works fine when there are 50 files in the folder.
Note that among the 50 files are those which are not included in the ZIP archive when the folder contains over 2,500 files and all 50 files are added successfully to the ZIP archive. Indeed I can extract them from the created ZIP and view them with Acrobat Reader without any problem.

Cheers,
Avi.
 
Paul Clapham
Sheriff
Posts: 28395
100
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In line 13, don't write the whole buffer. Just write the part of the buffer which the read() method filled.

As for the rest of your post, I think it says your problem is solved, although I find it difficult to extract a meaning from that sentence.
 
reply
    Bookmark Topic Watch Topic
  • New Topic