• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java Compress Multiple files as zip file  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
 
Sheriff
Posts: 22846
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!