choop
choop

Reputation: 921

Unzip files using ftp and java

I want to upload a zip file to the server using FTP protocol.
1. What is the best way to zip my files using java?
2. Later on I want to unzip the file in the server. How can I do it with FTP and java?

Thanks

Upvotes: 1

Views: 4238

Answers (3)

npinti
npinti

Reputation: 52185

The GZipStream classes (GZipOutputStream and GZipInputStream) should take care of the compression part. You can take a look here to see how you can compress files and this tutorial to uncompress the file. To upload the file through the use of FTP you can use Apache's FTPClient.

Upvotes: 2

UVM
UVM

Reputation: 9914

You can create zip file using ZIPOutputStream that is supported in Java.

take a look at here http://www.java-examples.com/create-zip-file-directory-using-zipoutputstream-example

Later on once you uploaded the file, you can unzip it using ZIPInputStream.

http://www.kodejava.org/examples/334.html

Upvotes: 1

ejb_guy
ejb_guy

Reputation: 1125

FTPClient in Appache Commons can help you in dealing with ftp. For zipping have a look at java.util.zip. I have used Zip I\O classes and found very easy to use

Upvotes: 0

Related Questions