/**
* 初始化ftp服务器
*/
private FTPClient initFtpClient() throws Exception {
String host = FamousClassRoomPropertiesConfig.getZjeduFileUploadHost();
int port = FamousClassRoomPropertiesConfig.getZjeduFileUploadPort();
String userName = FamousClassRoomPropertiesConfig.getZjeduFileUploadUsername();
String passworld = FamousClassRoomPropertiesConfig.getZjeduFileUploadPassword();
FTPClient ftpClient = new FTPClient();
ftpClient.setControlEncoding("utf-8");
//连接ftp服务器
ftpClient.connect(host, port);
//登录ftp服务器
ftpClient.login(userName, passworld);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
ftpClient.disconnect();
throw new Exception("连接服务器失败");
}
return ftpClient;
}
ftp 文件上传与删除
最新推荐文章于 2022-05-11 16:47:40 发布
本文介绍了如何使用FTP进行文件上传及删除操作。对于文件上传,详细讲述了步骤和注意事项;对于删除文件,同样给出了具体的操作流程,确保用户能顺利执行FTP任务。
摘要由CSDN通过智能技术生成