优化Ftp.download,返回false抛出异常(issue#3805@Github)

This commit is contained in:
Looly 2024-12-04 12:20:50 +08:00
parent 9997d72ef6
commit b361614003

View File

@ -706,9 +706,9 @@ public class CommonsFtp extends AbstractFtp {
* @param out 输出流下载的文件写出到这个流中 * @param out 输出流下载的文件写出到这个流中
* @param fileNameCharset 文件名编码通过此编码转换文件名编码为ISO8859-1 * @param fileNameCharset 文件名编码通过此编码转换文件名编码为ISO8859-1
* @throws IORuntimeException IO异常 * @throws IORuntimeException IO异常
* @since 5.5.7 * @return 是否下载成功
*/ */
public void download(final String path, String fileName, final OutputStream out, final Charset fileNameCharset) throws IORuntimeException { public boolean download(final String path, String fileName, final OutputStream out, final Charset fileNameCharset) throws IORuntimeException {
String pwd = null; String pwd = null;
if (this.backToPwd) { if (this.backToPwd) {
pwd = pwd(); pwd = pwd();
@ -723,7 +723,7 @@ public class CommonsFtp extends AbstractFtp {
} }
try { try {
client.setFileType(FTPClient.BINARY_FILE_TYPE); client.setFileType(FTPClient.BINARY_FILE_TYPE);
client.retrieveFile(fileName, out); return client.retrieveFile(fileName, out);
} catch (final IOException e) { } catch (final IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} finally { } finally {