package com.zehon.ftp.samples;
/**
* This CopyFolderSample
class
* This sample demonstrates how to copy a folder to another folder directly on the FTP server
* This sample uses a convenient method, for a Spring-able version of this refer to FTPClient
* @see com.zehon.ftp.FTPClient
* Please refer to http://www.zehon.com/features.htm for more information about our FTP.
* @author Zehon Team (we're happy to serve you!) http://www.zehon.com/
*
*/
import com.zehon.FileTransferStatus;
import com.zehon.exception.FileTransferException;
import com.zehon.ftp.FTP;
public class CopyFolderSample {
/**
* Please refer to http://www.zehon.com/FTP_samples.htm for its full source code
* @param args
*/
public static void main(String[] args) {
String host = "ftp.zehon.com";
String username = "ftp";
String password = "ftp";
String sourceFolderPath = "/upload";
String destFolderPath = "/uploadCopy";
try {
/* This sample uses a convenient method, for a Spring-able version of this refer to FTPClient
* @see com.zehon.ftp.FTPClient
*/
int status = FTP.copyFile(sourceFolderPath, destFolderPath, host, username, password);
if(FileTransferStatus.SUCCESS == status){
System.out.println(sourceFolderPath + " got copied-ed successfully to folder "+destFolderPath);
}
else if(FileTransferStatus.FAILURE == status){
System.out.println("Fail to copy to folder "+destFolderPath);
}
} catch (FileTransferException e) {
e.printStackTrace();
}
}
}