问题遇到的现象和发生背景
在ftp 下载文件时调用如下方法:出错
用代码块功能插入代码,请勿粘贴截图
```java
public static boolean download(FtpConfig ftpConfig, String ftpPath, String fileName, String rename, String localPath) {
boolean var5 = false;
FTPClient var6 = new FTPClient();
boolean var8;
try {
var6.connect(ftpConfig.getHost(), ftpConfig.getPort());
var6.setControlEncoding("UTF-8");
var6.login(ftpConfig.getUser(), ftpConfig.getPassword());
int var7 = var6.getReplyCode();
if (FTPReply.isPositiveCompletion(var7)) {
var6.setFileType(2);
var6.changeWorkingDirectory(ftpPath);
var6.enterLocalPassiveMode();
FTPFile[] var45 = var6.listFiles();
FTPFile[] var9 = var45;
int var10 = var45.length;
for(int var11 = 0; var11 < var10; ++var11) {
FTPFile var12 = var9[var11];
if (fileName.equalsIgnoreCase(var12.getName())) {
File var13 = new File(localPath);
if (!var13.exists()) {
boolean var14 = var13.mkdirs();
LOG.info("创建目录{}{}", var13.getAbsolutePath(), var14);
}
File var46 = new File(localPath + (StringUtils.isEmpty(rename) ? var12.getName() : rename));
FileOutputStream var15 = new FileOutputStream(var46);
Throwable var16 = null;
try {
var6.retrieveFile(var12.getName(), var15);
} catch (Throwable var41) {
var16 = var41;
throw var41;
} finally {
if (var15 != null) {
if (var16 != null) {
try {
var15.close();
} catch (Throwable var40) {
var16.addSuppressed(var40);
}
} else {
var15.close();
}
}
}
}
}
var6.logout();
var5 = true;
return var5;
}
var8 = var5;
} catch (Exception var43) {
LOG.error("FTP download error", var43);
return var5;
} finally {
if (var6.isConnected()) {
try {
var6.logout();
} catch (IOException var39) {
LOG.error("FTP logout error", var39);
}
}
}
return var8;
}
运行结果及报错内容
一直报Software caused connection abort: socket write error
我想要达到的结果
能正确ftp 下载