package com.zehon.ftps.samples;
/**
* This MoveFileSample
class
* This sample demonstrates how to move a file to another folder or to rename it directly on the FTPs server
* This sample uses a convenient method, for a Spring-able version of this refer to FTPsClient
* @see com.zehon.ftps.FTPsClient
* Please refer to http://www.zehon.com/features.htm for more information about our FTPs.
* @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.ftps.FTPs;
public class MoveFileSample {
/**
* Please refer to http://www.zehon.com/FTPs_samples.htm for its full source code
* @param args
*/
public static void main(String[] args) {
String ftpsFromFolder = "/test";
String nameOfFileToMove = "test.txt";
String ftpsToFolder = "/anotherfolder";
String newNameOfFile = "moved_test.txt";
try {
/*
* This sample uses a convenient method, for a Spring-able version
* of this refer to FTPsClient
*
* @see com.zehon.ftps.FTPsClient
*/
int status = FTPs.moveFile(nameOfFileToMove, ftpsFromFolder, newNameOfFile,
ftpsToFolder, "ftps.myhost.com", "ftps", "pass");
if (FileTransferStatus.SUCCESS == status) {
System.out.println(nameOfFileToMove
+ " got moved successfully to file "
+ newNameOfFile);
} else if (FileTransferStatus.FAILURE == status) {
System.out.println("Fail to move to folder " + ftpsToFolder);
}
} catch (FileTransferException e) {
e.printStackTrace();
}
}
}