principal-ideal-domain
principal-ideal-domain

Reputation: 4266

Very slow FTP download

I'm downloading a file from a FTP account using a self written function:

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;
}

client is a org.apache.commons.net.ftp.FTPClient object. Unfortunately the download speed of this function is very very slow. Why is this the case and how can I increase it?

Upvotes: 0

Views: 2254

Answers (2)

crigore
crigore

Reputation: 400

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

Upvotes: 3

Viktor Mellgren
Viktor Mellgren

Reputation: 4506

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

client.setBufferSize(1024*1024);

Upvotes: 1

Related Questions