【发布时间】:2020-04-27 20:58:38
【问题描述】:
当我尝试使用 FTPClient 检索文件时收到此消息:
Could not parse response code.
Server Reply:
150 Opening data channel for file download from server
我是如何连接的:
FTPClient ftpClient = new FTPClient();
ftpClient.setDefaultTimeout(this.timeout);
try {
ftpClient.connect(this.host, this.port);
ftpClient.setSoTimeout(this.timeout);
if (!ftpClient.login(username, password)) {
return null;
}
} catch (IOException e) {
return null;
}
导致问题的代码是:
File downloadedFile = new File(localFile);
try (OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(downloadedFile))) {
ftpClient.retrieveFile(remoteFilePath, outputStream);
}
当我通过 FTP 命令手动下载文件时,收到多行回复:
ftp> get file
local: file remote: file
200 Port command successful
150 Opening data channel for file download from server of "/file"
226 Successfully transferred "/file"
202 bytes received in 0.00 secs (1777.2 kB/s)
【问题讨论】:
-
显示log file。
标签: java ftp apache-commons