通过FTPClient下载进行目录下载:
首先确定一个FTP基本目录ftpBasePath和本地基本目录localBasePath;
然后设定需要下载的FTP目录ftpPath,其中,ftpPath是ftpBasePath下的一个子目录。即:ftpBasePath + “/” +
ftpPath是可以访问的目录。(类似于使用cute FTP客户端工具,先切换到某个目录,然后将改目录下面的某个子目录下载到本地localBasePath。)
通过递归方法,先下载目录下面的文件,然后,下载目录。
主类为:
private FTPClient ftpClient = new FTPClient();
public RecursionDownload(String ftpBasePath, String localBasePath) {
this.ftpBasePath = ftpBasePath;
this.localBasePath = localBasePath;
}
}
主要方法有:
切换FTP服务器目录;
核心方法是:
下载该FTP目录(是相对ftpBasePath的目录)到本地。
}
下载文件到本地目录的方法为:
下载目录到本地: