/** * The FTP client utility class. */ public class MyFtpClient { private FTPClient ftpClient; public String ip; public String port; public String username; public String password;
/** * Download to destination path.<br> * <B>Caution:</B>The destination path should include the file name.<br> * For example : the correct should be "d:/folder/1.txt" , not "d:/folder/" * * @param sour * @param dest * @throws RuntimeException */ public void download(String sour, String dest) throws RuntimeException { FTPClient ftpClient = new FTPClient(); FileOutputStream fos = null; try { if (null != port && !"".equals(port)) { ftpClient.connect(ip, Integer.parseInt(port)); } else { ftpClient.connect(ip); }
ftpClient.login(username, password);
String remoteFileName = sour; fos = new FileOutputStream(dest);