• 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:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Java Compress Multiple files as zip file

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am currently working on a project that requires me to compress log files.

I came across a problem when I have to compress multiple log files into a single file. I don't know how to do this. Please give me pointers or hints of how I can do this. Anything would be great.

Thanks,

Chue
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check these two classes.

java.util.zip.ZipOutputStream
and
java.util.zip.ZipEntry

ZipOutputStream has a putNextEntry(ZipEntry) method, that you can (after adding an entry) write to using ZipOutputSteram.write (from a FileInputStream of the file you wish do compress)
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
PLEASE ASK GOOGLE BEFORE ASKING PEOPLE.

zipping a file is so common that its impossible that you could have difficulties to find a way on the net the tells you how to do it.
 
Euck gany
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Omar Al Kababji wrote:PLEASE ASK GOOGLE BEFORE ASKING PEOPLE.

zipping a file is so common that its impossible that you could have difficulties to find a way on the net the tells you how to do it.



Just asking for a simple hint or clues of how to get this job done. That's what the net is for. I'm not asking to get spoon fed.
 
Euck gany
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sebastian Janisch wrote:Check these two classes.

java.util.zip.ZipOutputStream
and
java.util.zip.ZipEntry

ZipOutputStream has a putNextEntry(ZipEntry) method, that you can (after adding an entry) write to using ZipOutputSteram.write (from a FileInputStream of the file you wish do compress)




thanks
 
Marshal
Posts: 27371
88
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

Euck gany wrote:

Omar Al Kababji wrote:PLEASE ASK GOOGLE BEFORE ASKING PEOPLE.

zipping a file is so common that its impossible that you could have difficulties to find a way on the net the tells you how to do it.



Just asking for a simple hint or clues of how to get this job done. That's what the net is for. I'm not asking to get spoon fed.



Omar said that a bit too harshly, but I used "java zip tutorial" as my Google keywords and the first link it returned was a Sun tutorial about how to do that, complete with example code. Yes, that is what the net -- and Google -- are for.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic