0

I want to make the file to zip . I can make the file to zip file but I don't want to create temporary zip file. Is any way to make the file to zip and to byte[] ? Thanks

J.Joe
  • 81
  • 1
  • 7
  • Why? Are you aware you can write it directly to any `OutputStream`, not just a file? Do you *really* need the entire ZIP file in memory? It's not an approach that will scale. – user207421 Mar 13 '17 at 07:26
  • I'm working on a web project ,i need to zip the files and let users download it , so i think make the files to zip and store it in disk and deleted the temporary zip is a spot of bother. So i decided make the zip file in memory . – J.Joe Mar 13 '17 at 07:32

1 Answers1

1

zip files are typically generated with streams anyway, so there's no need to temporarily store them in a file - might as well be in memory or streamed directly to a remote recipient (with only a small memory buffer to avoid a large memory footprint). Ref Sample helperclass in the accepted answer section How can I generate zip file without saving to the disk with Java?

Community
  • 1
  • 1
Senthil
  • 2,156
  • 1
  • 14
  • 19