|
@@ -38,6 +38,12 @@ public class FtpUtil {
|
|
|
ftpClient.setControlEncoding("utf-8");
|
|
|
try {
|
|
|
ftpClient.connect(hostname, port);
|
|
|
+ //设置连接连接超时时间
|
|
|
+ ftpClient.setConnectTimeout(4*1000);
|
|
|
+ //设置连接时间读取超时时间
|
|
|
+ ftpClient.setDefaultTimeout(4*1000);
|
|
|
+ //设置数据读取超时的时间
|
|
|
+ ftpClient.setDataTimeout(4*1000);
|
|
|
ftpClient.login(username, password);
|
|
|
int replyCode = ftpClient.getReplyCode();
|
|
|
if (!FTPReply.isPositiveCompletion(replyCode)) {
|
|
@@ -242,6 +248,7 @@ public class FtpUtil {
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
+ closeFtpClient(ftpClient);
|
|
|
return localNewFiles;
|
|
|
}
|
|
|
|