/**
* 初始化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 发布