Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in Java FTP by (820 points)
I'm trying to implement an FTP downloader that will allow me to list the files in the directory, and pass off all of the files that need downloading to multiple worker threads. In my google searches, this attracted me to edtFTPj/PRO, since it appears that the SecureFileTransferClient class can do this. However, I want to each file to download to a byte array, not to a file on the local filesystem, as I then need to process these files. They are generally smallish in size, and can fit in memory.

I then found AsyncFileTransferClient (Javadoc is amazing), which looks like I can do what I want with downloadByteArrayAsync() which, with the callback, looks exactly like what I want. Thanks!

I do have a question on AsyncFileTransferClient though. In the Javadoc for it, it shows using connectAsync(). Can I safely assume that I can simply call connect() instead, and have it use the normal blocking behavior and not return until it has successfully established the main FTP connection, as well as the created the worker threads? I can safely use all of the blocking methods of SecureFileTransferClient, such as directoryNameList(), and then simply use downloadByteArrayAsync() to download the files?

If I call AsyncFileTransferClient.changeDirectory(), will the directory change will be mirrored to the worker threads when I use downloadByteArrayAsync()? Or will I have to pass the full path name when using downloadByteArrayAsync()?

Last, I don't see a AsyncFileTransferClient.login() method. Does this mean I need to set AsyncFileTransferClient.getAdvancedSettings().setAutoLogin(true), or will it login automatically even if I don't set that?

3 Answers

0 votes
by (51.6k points)
Hi Aaron

I do have a question on AsyncFileTransferClient though. In the Javadoc for it, it shows using connectAsync(). Can I safely assume that I can simply call connect() instead, and have it use the normal blocking behavior and not return until it has successfully established the main FTP connection, as well as the created the worker threads?


Yes you can.

I can safely use all of the blocking methods of SecureFileTransferClient, such as directoryNameList(), and then simply use downloadByteArrayAsync() to download the files?


Yes you can.

If I call AsyncFileTransferClient.changeDirectory(), will the directory change will be mirrored to the worker threads when I use downloadByteArrayAsync()?


Yes it will

Or will I have to pass the full path name when using downloadByteArrayAsync()?


You can do that too, but it shouldn't be necessary.

Last, I don't see a AsyncFileTransferClient.login() method. Does this mean I need to set AsyncFileTransferClient.getAdvancedSettings().setAutoLogin(true), or will it login automatically even if I don't set that?


Auto-login is enabled by default. You just need to set up the credentials (user-name, password, etc) before calling connect.

- Hans (EnterpriseDT)
0 votes
by (820 points)
Thanks Hans! Good answers :)

Just a thought, but maybe update the Javadoc for AsyncFileTransferClient to point out that the child workers change directory as well when the directory is changed by the main object.
0 votes
by (51.6k points)
Thanks Hans! Good answers :)

Just a thought, but maybe update the Javadoc for AsyncFileTransferClient to point out that the child workers change directory as well when the directory is changed by the main object.


Your wish is my command. :wink:

- Hans (EnterpriseDT)

Categories

...