commons-net的用法
这几天用到了一个第三方FTP的jar包 这里用的版本是commons-net-3.3
下面我们分为两部分来查看 上传和下载
先来看上传
上传的用法很简单
第一步:先创建 FTPClient对象 并初始化
/**
* FTP连接
*/
private FTPClient ftpClient;
/**
* 构造函数.通过构造 在调用方传过来域名 用户名 和密码
*
* @param host hostName 服务器名
* @param user userName 用户名
* @param pass password 密码
*/
public FTPManager(String host, String user, String pass) {
this.hostName = host;
this.userName = user;
this.password = pass;
this.ftpClient = new FTPClient();
this.list = new ArrayList();
}
第二步 打开连接
/**
* 打开FTP服务.
*
* @throws IOException
*/
public void openConnect() throws IOException {
// 中文转码
ftpClient.setControlEncoding("UTF-8");</