FTP下载速度很慢

时间:2015-06-15 14:13:20

标签: java download ftp

我正在使用自编函数从FTP帐户下载文件:

private boolean download(String path, Path target) throws IOException {
    FileOutputStream fos = new FileOutputStream(target.toString());
    boolean download = client.retrieveFile(path, fos);
    fos.close();
    return download;
}

clientorg.apache.commons.net.ftp.FTPClient个对象。不幸的是,这个功能的下载速度非常慢。为什么会这样,我该如何增加它?

2 个答案:

答案 0 :(得分:2)

If I'm not wrong, you can try increasing the buffer size of your client object, like this:client.setBufferSize(1024000);

This will decrease the buffer copies on your end, and speed up the download, as commented in SpeedUp FTPClient

答案 1 :(得分:1)

Before you do the retrieve, or where you setup your client, try increasing the buffer size.

client.setBufferSize(1024*1024);