package com.zehon.scp.samples;
/**
* This DownloadFileSample
class
* This sample demonstrates how to download a file via SCP
* Please refer to http://www.zehon.com/features.htm for more information about our SCP.
* @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.scp.SCP;
public class DownloadFileSample {
public static void main(String[] args) {
String host = "scp.zehon.com";
String username = "scp";
String password = "scp";
String scpFolder = "/test";
String writeToLocalFolder = "C:\\myfiles\\writeToFolder";
String nameOfFile = "testStream.txt";
try {
int status = SCP.getFile(nameOfFile, scpFolder, host, username, password, writeToLocalFolder);
if(FileTransferStatus.SUCCESS == status){
System.out.println(nameOfFile + " got downloaded successfully to folder "+writeToLocalFolder);
}
else if(FileTransferStatus.FAILURE == status){
System.out.println("Fail to download to folder "+writeToLocalFolder);
}
} catch (FileTransferException e) {
e.printStackTrace();
}
}
}