标签:ftpclient 依赖 user rect java mode put log ftp
1.添加依赖
commons-net-3.6.jar
2.获取ftp客户端
ftpClient = new FTPClient();
ftpClient.connect(ip, port);
ftpClient.login(username, password);
ftpClient.setBufferSize(8096);
ftpClient.changeWorkingDirectory("/root");
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
ftpClient.enterLocalPassiveMode();
3.下载
remote = new String((ftpClient.printWorkingDirectory() + filepath).getBytes("gbk"), "ISO885901");
file = new File(local);
ftpClient.retrieveFile(remote, new FileOutputStream(file));
4.上传
remote = new String((ftpClient.printWorkingDirectory() + filepath).getBytes("gbk"), "ISO885901");
file = new File(local);
ctpClient.makeDirectory((ftpClient.printWorkingDirectory() + filepath).getBytes("gbk"), "ISO885901");
ftpClient.storeFile(remote, new FileOutputStream(file));
标签:ftpclient 依赖 user rect java mode put log ftp
原文地址:https://www.cnblogs.com/blog-ice/p/9228300.html