Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Archive a folder in Java using truezip

I need to create a service that finds specific folders and archives them into on zip file.

I saw all kind of examples, but it seems that have to read all the files in every folder. Am I right?

Is there another way to do that (maybe using truezip for that matter)?

I want to use truezip since I understood you could easily add files/folders to a zip file.

I've searched for a simple example of archiving a folder using truezip - but I couldn't find anything useful - I need a simple example of how to archive a given folder.

I'm using Java 6. How to archive a folder in Java using truezip?

EDIT: Also found this example.

like image 419
Noam Avatar asked Aug 11 '26 00:08

Noam


1 Answers

Using TrueZIP, all you need to call is

new TFile("folder").cp_rp(new TFile("archive.zip"));

I suggest to read it's tutorial in order to get a better understanding of what it all means: TrueZIP Tutorial

like image 168
Christian Schlichtherle Avatar answered Aug 12 '26 15:08

Christian Schlichtherle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!