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