Package com.enterprisedt.net.ftp
Class AsyncFileTransferClient
java.lang.Object
com.enterprisedt.net.ftp.SecureFileTransferClient
com.enterprisedt.net.ftp.AsyncFileTransferClient
- All Implemented Interfaces:
FileTransferClientInterface
FTP client class supporting multiple protocols that permits asynchronous FTP operations. Together with
the connection pool inherited from SecureFileTransferClient, this means that
multiple simultaneous file transfers can be performed in the background.
A simple example of connecting asynchronously is shown below. The MyConnectTest class is implementing the callback, passing itself via the 'this' reference into connectAsync():
public class MyConnectTest implements Connect {
private AsyncFileTransferClient client = new AsyncFileTransferClient();
public void startConnecting() {
client.setRemoteHost(host);
client.setUserName(user);
client.setPassword(password);
client.connectAsync(this, null);
}
public void onConnect(ConnectResult result)
throws FTPException, IOException {
result.endAsync();
System.out.println("Connected!")
}
Users should note that calling asyncConnect() starts a pool of worker threads and the
connection pool. This means that asyncDisconnect() (or disconnect()) must be called to stop the
worker threads, otherwise applications will hang on exit as threads will still
be alive.
- Version:
- $Revision$
- Author:
- Bruce Blackshaw
-
Field Summary
Fields inherited from class com.enterprisedt.net.ftp.SecureFileTransferClient
activeTransferTasks, advancedFTPSettings, advancedSettings, advancedSSHSettings, advancedSSLSettings, asyncImpl, eventListener, masterContext, multiSettings, proxySettings -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.AsyncFileTransferClient(int initialPoolSize, int maxPoolSize) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidchangeDirectory(String directoryName) Change directory on the FTP server.changeDirectoryAsync(String directoryName, AsyncCallback.ChangeDirectory callback, Object tag) Change directory on the FTP server asynchronously.changeToParentDirectoryAsync(AsyncCallback.ChangeDirectory callback, Object tag) Change directory on the FTP server asynchronously.connectAsync(AsyncCallback.Connect callback, Object tag) Make an asynchronous connection to the FTP server.createDirectoryAsync(String directoryName, AsyncCallback.CreateDirectory callback, Object tag) Change directory on the FTP server asynchronously.deleteDirectoryAsync(String directoryName, boolean recursive, AsyncCallback.DeleteDirectory callback, Object tag) Delete a directory on the FTP server asynchronously, and optionally sub-directories.deleteDirectoryAsync(String directoryName, AsyncCallback.DeleteDirectory callback, Object tag) Delete a directory on the FTP server asynchronously.deleteFileAsync(String remoteFileName, AsyncCallback.DeleteFile callback, Object tag) Deletes a remote file asynchronously.deleteMultipleFilesAsync(FileFilter filter, AsyncCallback.DeleteMultipleFiles callback, Object tag) Deletes remote files in the current directory that match the supplied wildcarddeleteMultipleFilesAsync(String wildcard, AsyncCallback.DeleteMultipleFiles callback, Object tag) Deletes remote files in the current directory that match the supplied wildcarddeleteMultipleFilesAsync(String remoteDirectory, FileFilter filter, boolean recursive, AsyncCallback.DeleteMultipleFiles callback, Object tag) Deletes remote files that match the supplied wildcard in the supplied remote directory asynchronously.deleteMultipleFilesAsync(String remoteDirectory, String wildcard, boolean recursive, AsyncCallback.DeleteMultipleFiles callback, Object tag) Deletes remote files that match the supplied wildcard in the supplied remote directory asynchronously.directoryListAsync(String directoryName, AsyncCallback.DirectoryList callback, Object tag) List a directory on the FTP server asynchronously.directoryNameListAsync(String directoryName, boolean isLongListing, AsyncCallback.DirectoryNameList callback, Object tag) List a directory on the FTP server asynchronously.disconnectAsync(boolean immediate, AsyncCallback.Disconnect callback, Object tag) Disconnect from the FTP server asynchronously.disconnectAsync(AsyncCallback.Disconnect callback, Object tag) Disconnect from the FTP server asynchronously.downloadByteArrayAsync(String remoteFileName, AsyncCallback.DownloadByteArray callback, Object tag) Download a file from the FTP server asynchronously to a byte arraydownloadFileAsync(String localFileName, String remoteFileName, WriteMode writeMode, AsyncCallback.DownloadFile callback, Object tag) Download a file from the FTP server asynchronously.downloadMultipleAsync(String localDir, FileFilter filter, AsyncCallback.DownloadMultiple callback, Object tag) Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory.downloadMultipleAsync(String localDir, String wildcard, AsyncCallback.DownloadMultiple callback, Object tag) Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory.downloadMultipleAsync(String localDir, String remoteDir, FileFilter filter, boolean recursive, AsyncCallback.DownloadMultiple callback, Object tag) Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory.downloadMultipleAsync(String localDir, String remoteDir, String wildcard, boolean recursive, AsyncCallback.DownloadMultiple callback, Object tag) Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory.downloadStreamAsync(String remoteFileName, AsyncCallback.DownloadStream callback, Object tag) Download a file from the FTP server as a stream, asynchronously.executeCommandAsync(String command, AsyncCallback.ExecuteCommand callback, Object tag) Request that the remote server execute the literal command supplied.existsAsync(String remoteFileName, AsyncCallback.Exists callback, Object tag) Determine asynchronously if a remote file exists.Get the current content type.Get the currently set disconnect callback.getModifiedTimeAsync(String remoteFileName, AsyncCallback.GetModifiedTime callback, Object tag) Get the modified-time of a remote file asynchronously.getSizeAsync(String remoteFileName, AsyncCallback.Size callback, Object tag) Get the size of a remote file asynchronously.getSystemTypeAsync(AsyncCallback.GetSystemType callback, Object tag) Get a string that represents the remote system that the client is logged into.booleanGet the detect content type flag.renameAsync(String renameFromName, String renameToName, AsyncCallback.Rename callback, Object tag) Rename a remote file asynchronously.voidSet the transfer type, either ASCII or binary.voidsetDetectContentType(boolean detectContentType) Set auto detect of filetypes on or off.voidSet the callback that is called for all disconnects - deliberate and resulting from timeout or error.setModifiedTimeAsync(String remoteFileName, Date modifiedTime, AsyncCallback.SetModifiedTime callback, Object tag) Set the modified-time of a remote file asynchronously.setPermissionsAsync(String remotePath, int permissions, AsyncCallback.SetPermissions callback, Object tag) Set the permissions of the supplied file or directory.uploadByteArrayAsync(byte[] bytes, String remoteFileName, WriteMode writeMode, AsyncCallback.UploadByteArray callback, Object tag) Upload a byte array to the FTP server asynchronously.uploadFileAsync(String localFileName, String remoteFileName, AsyncCallback.UploadFile callback, Object tag) Upload a file to the FTP server asynchronously.uploadFileAsync(String localFileName, String remoteFileName, WriteMode writeMode, AsyncCallback.UploadFile callback, Object tag) Upload a file to the FTP server asynchronously.uploadMultipleAsync(String localDir, FileFilter filter, AsyncCallback.UploadMultiple callback, Object tag) Uploads local files from the supplied local directory that match the supplied FileFilter into the current remote directory.uploadMultipleAsync(String localDir, String wildcard, AsyncCallback.UploadMultiple callback, Object tag) Uploads local files from the supplied local directory that match the supplied wildcard into the current remote directory.uploadMultipleAsync(String localDir, String remoteDir, FileFilter filter, boolean recursive, AsyncCallback.UploadMultiple callback, Object tag) Uploads local files from the supplied local directory that match the supplied wildcard into the supplied remote directory.uploadMultipleAsync(String localDir, String remoteDir, String wildcard, boolean recursive, AsyncCallback.UploadMultiple callback, Object tag) Uploads local files from the supplied local directory that match the supplied wildcard into the supplied remote directory.uploadStreamAsync(String remoteFileName, AsyncCallback.UploadStream callback, Object tag) Upload a file to the FTP server by writing to a stream, asynchronously.uploadStreamAsync(String remoteFileName, WriteMode writeMode, AsyncCallback.UploadStream callback, Object tag) Upload a file to the FTP server by writing to a stream, asynchronously.Methods inherited from class com.enterprisedt.net.ftp.SecureFileTransferClient
addErrorListener, cancelAllTransfers, changeIntoPathDirectory, changeToParentDirectory, checkConnection, connect, createDirectory, deleteDirectory, deleteDirectory, deleteFile, deleteMultipleFiles, deleteMultipleFiles, deleteMultipleFiles, deleteMultipleFiles, directoryList, directoryList, directoryList, directoryNameList, directoryNameList, disconnect, disconnect, downloadByteArray, downloadFile, downloadFile, downloadMultiple, downloadMultiple, downloadMultiple, downloadMultiple, downloadStream, downloadURLFile, downloadURLStream, executeCommand, exists, existsDirectory, finalize, getAdvancedFTPSettings, getAdvancedSettings, getAdvancedSSHSettings, getAdvancedSSLSettings, getInitialRemoteDirectory, getLastReply, getMaxTransferRate, getModifiedTime, getMultipleTransferSettings, getNetworkBufferSize, getPassword, getProtocol, getProxySettings, getRemoteDirectory, getRemoteHost, getRemotePort, getSize, getStatistics, getSystemType, getTimeout, getUserName, isCompressionPreferred, isConnected, isKeepAliveEnabled, isServerValidationEnabled, isTransferIntegrityCheck, loadSSHServerValidation, loadSSLServerValidation, rename, setChangeIntoPathDirectory, setCompressionPreferred, setEventListener, setInitialRemoteDirectory, setKeepAliveEnabled, setMaxTransferRate, setModifiedTime, setNetworkBufferSize, setPassword, setPermissions, setProtocol, setRemoteHost, setRemotePort, setServerValidationEnabled, setTimeout, setTransferIntegrityCheck, setUserName, shutdown, uploadByteArray, uploadFile, uploadFile, uploadMultiple, uploadMultiple, uploadMultiple, uploadMultiple, uploadStream, uploadStream, uploadURLFile, uploadURLStream
-
Constructor Details
-
AsyncFileTransferClient
public AsyncFileTransferClient(int initialPoolSize, int maxPoolSize) Constructor. Initialises the class.- Parameters:
poolsize- size of connection pool (i.e. number of managed connections)
-
AsyncFileTransferClient
public AsyncFileTransferClient()Default constructor. Uses defaults for pool sizes.
-
-
Method Details
-
setContentType
Set the transfer type, either ASCII or binary. Setting applies to all subsequent transfers that are initiated. It does not apply to transfers currently in progress.If called within a callback, will only apply to the callback context, not to all connections.- Specified by:
setContentTypein interfaceFileTransferClientInterface- Overrides:
setContentTypein classSecureFileTransferClient- Parameters:
type- transfer type- Throws:
FTPExceptionIOExceptionFTPException
-
getContentType
Get the current content type. If called within a callback, will only apply to the callback context, not to all connections.- Specified by:
getContentTypein interfaceFileTransferClientInterface- Overrides:
getContentTypein classSecureFileTransferClient- Returns:
- transfer type
-
setDetectContentType
public void setDetectContentType(boolean detectContentType) Set auto detect of filetypes on or off. If on, the transfer mode is switched from ASCII to binary and vice versa depending on the extension of the file. After the transfer, the mode is always returned to what it was before the transfer was performed. The default is off. If called within a callback, will only apply to the callback context, not to all connections. If the filetype is unknown, the transfer mode is unchanged- Specified by:
setDetectContentTypein interfaceFileTransferClientInterface- Overrides:
setDetectContentTypein classSecureFileTransferClient- Parameters:
detectContentType- true if detecting content type, false if not
-
isDetectContentType
public boolean isDetectContentType()Get the detect content type flag. If called within a callback, will only apply to the callback context, not to all connections.- Specified by:
isDetectContentTypein interfaceFileTransferClientInterface- Overrides:
isDetectContentTypein classSecureFileTransferClient- Returns:
- true if we are detecting binary and ASCII transfers from the file type
-
connectAsync
Make an asynchronous connection to the FTP server. A number of connections are made - that number being equal to the size of the FTP connection pool.- Parameters:
callback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback). Can be set to null.- Returns:
- result object
- Throws:
FTPException
-
executeCommandAsync
public ExecuteCommandResult executeCommandAsync(String command, AsyncCallback.ExecuteCommand callback, Object tag) throws FTPException Request that the remote server execute the literal command supplied. In FTP and SFTP, this might be a SITE command, while in SFTP it might be a shell command.It is up to the user to send a sensible command.
- Parameters:
command- command string- Returns:
- result string by server
- Throws:
FTPExceptionIOException
-
getSystemTypeAsync
public GetSystemTypeResult getSystemTypeAsync(AsyncCallback.GetSystemType callback, Object tag) throws FTPException Get a string that represents the remote system that the client is logged into.- Parameters:
command- command string- Returns:
- result string by server
- Throws:
FTPExceptionIOException
-
directoryNameListAsync
public DirectoryNameListResult directoryNameListAsync(String directoryName, boolean isLongListing, AsyncCallback.DirectoryNameList callback, Object tag) throws FTPException List a directory on the FTP server asynchronously.- Parameters:
directoryName- name of the directory (generally not a path)isLongListing- true if the listing is a long format listingcallback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
directoryListAsync
public DirectoryListResult directoryListAsync(String directoryName, AsyncCallback.DirectoryList callback, Object tag) throws FTPException List a directory on the FTP server asynchronously.- Parameters:
directoryName- name of the directory (generally not a path)callback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadByteArrayAsync
public DownloadByteArrayResult downloadByteArrayAsync(String remoteFileName, AsyncCallback.DownloadByteArray callback, Object tag) throws FTPException Download a file from the FTP server asynchronously to a byte array- Parameters:
remoteFileName- name of the remote file to be downloadedcallback- callback to be notified when download is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadFileAsync
public DownloadFileResult downloadFileAsync(String localFileName, String remoteFileName, WriteMode writeMode, AsyncCallback.DownloadFile callback, Object tag) throws FTPException Download a file from the FTP server asynchronously.- Parameters:
localFileName- name (or full path) of the local file to be downloaded toremoteFileName- name of the remote file to be downloadedwriteMode- mode in which the file is written to the servercallback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadStreamAsync
public DownloadStreamResult downloadStreamAsync(String remoteFileName, AsyncCallback.DownloadStream callback, Object tag) throws FTPException Download a file from the FTP server as a stream, asynchronously.- Parameters:
remoteFileName- name of the remote file to be downloadedcallback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadFileAsync
public UploadFileResult uploadFileAsync(String localFileName, String remoteFileName, AsyncCallback.UploadFile callback, Object tag) throws FTPException Upload a file to the FTP server asynchronously. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from .- Parameters:
localFileName- name (or full path) of the local file to be downloaded toremoteFileName- name of the remote file to be downloaded (or null to generate a unique name)callback- callback to be notified when upload is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadFileAsync
public UploadFileResult uploadFileAsync(String localFileName, String remoteFileName, WriteMode writeMode, AsyncCallback.UploadFile callback, Object tag) throws FTPException Upload a file to the FTP server asynchronously. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from .- Parameters:
localFileName- name (or full path) of the local file to be downloaded toremoteFileName- name of the remote file to be downloaded (or null to generate a unique name)writeMode- mode in which the file is written to the servercallback- callback to be notified when upload is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadByteArrayAsync
public UploadByteArrayResult uploadByteArrayAsync(byte[] bytes, String remoteFileName, WriteMode writeMode, AsyncCallback.UploadByteArray callback, Object tag) throws FTPException Upload a byte array to the FTP server asynchronously. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from .- Parameters:
bytes- byte array to uploadremoteFileName- name of the remote filewriteMode- mode in which the file is written to the servercallback- callback to be notified when upload is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadStreamAsync
public UploadStreamResult uploadStreamAsync(String remoteFileName, AsyncCallback.UploadStream callback, Object tag) throws FTPException Upload a file to the FTP server by writing to a stream, asynchronously. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from .- Parameters:
remoteFileName- name of the remote file to be uploadedcallback- callback to be notified when upload is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadStreamAsync
public UploadStreamResult uploadStreamAsync(String remoteFileName, WriteMode writeMode, AsyncCallback.UploadStream callback, Object tag) throws FTPException Upload a file to the FTP server by writing to a stream, asynchronously. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from .- Parameters:
remoteFileName- name of the remote file to be uploadedwriteMode- mode in which the file is written to the servercallback- callback to be notified when upload is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
getSizeAsync
public SizeResult getSizeAsync(String remoteFileName, AsyncCallback.Size callback, Object tag) throws FTPException Get the size of a remote file asynchronously.- Parameters:
remoteFileName- name of remote filecallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
getModifiedTimeAsync
public ModifiedTimeResult getModifiedTimeAsync(String remoteFileName, AsyncCallback.GetModifiedTime callback, Object tag) throws FTPException Get the modified-time of a remote file asynchronously.- Parameters:
remoteFileName- name of remote filecallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
setModifiedTimeAsync
public ModifiedTimeResult setModifiedTimeAsync(String remoteFileName, Date modifiedTime, AsyncCallback.SetModifiedTime callback, Object tag) throws FTPException Set the modified-time of a remote file asynchronously.- Parameters:
remoteFileName- name of remote filemodifiedTime- modified time to setcallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
setPermissionsAsync
public PermissionsResult setPermissionsAsync(String remotePath, int permissions, AsyncCallback.SetPermissions callback, Object tag) throws FTPException, IOException Set the permissions of the supplied file or directory. Only supported in SFTP.Absolute modes are octal numbers specifying the complete list of attributes for the files; you specify attributes by OR'ing together these bits. These must be octal numbers, and are listed below.
For example, for individual read, write and execute only, 0700 should be supplied (0400 | 0200 | 0100).0400 Individual read 0200 Individual write 0100 Individual execute (or list directory) 0040 Group read 0020 Group write 0010 Group execute 0004 Other read 0002 Other write 0001 Other execute
- Parameters:
remotePath- path of file or directorypermissions- octal permissions (must be preceded with a '0').callback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPExceptionIOException
-
existsAsync
public ExistsResult existsAsync(String remoteFileName, AsyncCallback.Exists callback, Object tag) throws FTPException Determine asynchronously if a remote file exists.- Parameters:
remoteFileName- name of remote filecallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
deleteFileAsync
public DeleteFileResult deleteFileAsync(String remoteFileName, AsyncCallback.DeleteFile callback, Object tag) throws FTPException Deletes a remote file asynchronously.- Parameters:
remoteFileName- name of remote filecallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
deleteMultipleFilesAsync
public DeleteMultipleFilesResult deleteMultipleFilesAsync(FileFilter filter, AsyncCallback.DeleteMultipleFiles callback, Object tag) throws FTPException Deletes remote files in the current directory that match the supplied wildcard- Parameters:
filter- filename filtercallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Throws:
FTPExceptionIOException
-
deleteMultipleFilesAsync
public DeleteMultipleFilesResult deleteMultipleFilesAsync(String wildcard, AsyncCallback.DeleteMultipleFiles callback, Object tag) throws FTPException Deletes remote files in the current directory that match the supplied wildcard- Parameters:
wildcard- wildcard string (supporting '*' and '?')- Throws:
FTPExceptionIOException
-
deleteMultipleFilesAsync
public DeleteMultipleFilesResult deleteMultipleFilesAsync(String remoteDirectory, String wildcard, boolean recursive, AsyncCallback.DeleteMultipleFiles callback, Object tag) throws FTPException Deletes remote files that match the supplied wildcard in the supplied remote directory asynchronously.- Parameters:
remoteDirectory- name of remote directorywildcard- wildcard string (supporting '*' and '?')callback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
deleteMultipleFilesAsync
public DeleteMultipleFilesResult deleteMultipleFilesAsync(String remoteDirectory, FileFilter filter, boolean recursive, AsyncCallback.DeleteMultipleFiles callback, Object tag) throws FTPException Deletes remote files that match the supplied wildcard in the supplied remote directory asynchronously.- Parameters:
remoteDirectory- name of remote directoryfilter- filename filtercallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
renameAsync
public RenameResult renameAsync(String renameFromName, String renameToName, AsyncCallback.Rename callback, Object tag) throws FTPException Rename a remote file asynchronously.- Parameters:
renameFromName- original namerenameToName- new namecallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
changeDirectory
Change directory on the FTP server. The working directory for subsequent asynchronous operations will be changed also.- Specified by:
changeDirectoryin interfaceFileTransferClientInterface- Overrides:
changeDirectoryin classSecureFileTransferClient- Parameters:
directoryName- name the remote directory to change into- Throws:
FTPExceptionIOException
-
changeDirectoryAsync
public ChangeDirectoryResult changeDirectoryAsync(String directoryName, AsyncCallback.ChangeDirectory callback, Object tag) throws FTPException Change directory on the FTP server asynchronously. . All async operations performed after this has completed will use the new directory.- Parameters:
directoryName- name the remote directory to change intocallback- callback to be notified when the directory change is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
changeToParentDirectoryAsync
public ChangeDirectoryResult changeToParentDirectoryAsync(AsyncCallback.ChangeDirectory callback, Object tag) throws FTPException Change directory on the FTP server asynchronously.- Parameters:
callback- callback to be notified when the directory change is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
createDirectoryAsync
public CreateDirectoryResult createDirectoryAsync(String directoryName, AsyncCallback.CreateDirectory callback, Object tag) throws FTPException Change directory on the FTP server asynchronously.- Parameters:
directoryName- name the remote directory to change intocallback- callback to be notified when the directory change is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
deleteDirectoryAsync
public DeleteDirectoryResult deleteDirectoryAsync(String directoryName, AsyncCallback.DeleteDirectory callback, Object tag) throws FTPException Delete a directory on the FTP server asynchronously. The directory must be empty, and not the current directory.- Parameters:
directoryName- name the remote directory to deletecallback- callback to be notified when the directory change is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
deleteDirectoryAsync
public DeleteDirectoryResult deleteDirectoryAsync(String directoryName, boolean recursive, AsyncCallback.DeleteDirectory callback, Object tag) throws FTPException Delete a directory on the FTP server asynchronously, and optionally sub-directories. The directory must not be the current directory. The directory must be empty for a non-recursive delete.- Parameters:
directoryName- name the remote directory to deleterecursive-callback- callback to be notified when the directory delete is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadMultipleAsync
public UploadMultipleResult uploadMultipleAsync(String localDir, FileFilter filter, AsyncCallback.UploadMultiple callback, Object tag) throws FTPException Uploads local files from the supplied local directory that match the supplied FileFilter into the current remote directory. Not recursive. Operation is asynchronous.- Parameters:
localDir- name of local directoryfilter- filename filtercallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadMultipleAsync
public UploadMultipleResult uploadMultipleAsync(String localDir, String wildcard, AsyncCallback.UploadMultiple callback, Object tag) throws FTPException Uploads local files from the supplied local directory that match the supplied wildcard into the current remote directory. Not recursive. Operation is asynchronous.- Parameters:
localDir- name of local directorywildcard- wildcard filter for files to be uploaded (supports '*' and '?')callback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadMultipleAsync
public UploadMultipleResult uploadMultipleAsync(String localDir, String remoteDir, String wildcard, boolean recursive, AsyncCallback.UploadMultiple callback, Object tag) throws FTPException Uploads local files from the supplied local directory that match the supplied wildcard into the supplied remote directory. If recursive is set to true, goes through all subdirectories. Operation is asynchronous.- Parameters:
localDir- name of local directoryremoteDir- name of remote directorywildcard- wildcard filter for files to be uploaded (supports '*' and '?')recursive- if true, operation is recursive through subdirectoriescallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
uploadMultipleAsync
public UploadMultipleResult uploadMultipleAsync(String localDir, String remoteDir, FileFilter filter, boolean recursive, AsyncCallback.UploadMultiple callback, Object tag) throws FTPException Uploads local files from the supplied local directory that match the supplied wildcard into the supplied remote directory. If recursive is set to true, goes through all sub-directories. Operation is asynchronous.- Parameters:
localDir- name of local directoryremoteDir- name of remote directoryfilter- filename filter for files to be uploadedrecursive- if true, operation is recursive through sub-directoriescallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadMultipleAsync
public DownloadMultipleResult downloadMultipleAsync(String localDir, FileFilter filter, AsyncCallback.DownloadMultiple callback, Object tag) throws FTPException Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory. Not recursive. Operation is asynchronous.- Parameters:
localDir- name of local directoryfilter- filename filtercallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadMultipleAsync
public DownloadMultipleResult downloadMultipleAsync(String localDir, String wildcard, AsyncCallback.DownloadMultiple callback, Object tag) throws FTPException Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory. Not recursive. Operation is asynchronous.- Parameters:
localDir- name of local directorywildcard- wildcard filter for files to be uploaded (supports '*' and '?')callback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadMultipleAsync
public DownloadMultipleResult downloadMultipleAsync(String localDir, String remoteDir, String wildcard, boolean recursive, AsyncCallback.DownloadMultiple callback, Object tag) throws FTPException Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory. If recursive is set to true, goes through all sub-directories. Operation is asynchronous.- Parameters:
localDir- name of local directoryremoteDir- name of remote directorywildcard- wildcard filter for files to be uploaded (supports '*' and '?')recursive- if true, operation is recursive through sub-directoriescallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
downloadMultipleAsync
public DownloadMultipleResult downloadMultipleAsync(String localDir, String remoteDir, FileFilter filter, boolean recursive, AsyncCallback.DownloadMultiple callback, Object tag) throws FTPException Downloads remote files to the supplied local directory that match the supplied wildcard from the current remote directory. If recursive is set to true, goes through all sub-directories. Operation is asynchronous.- Parameters:
localDir- name of local directoryremoteDir- name of remote directoryfilter- filename filter for files to be uploadedrecursive- if true, operation is recursive through sub-directoriescallback- callback to be notified when operation is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
setDisconnectCallback
Set the callback that is called for all disconnects - deliberate and resulting from timeout or error.- Parameters:
callback- callback to notify
-
getDisconnectCallback
Get the currently set disconnect callback.- Returns:
- callback notified on disconnection
-
disconnectAsync
public DisconnectResult disconnectAsync(AsyncCallback.Disconnect callback, Object tag) throws FTPException Disconnect from the FTP server asynchronously. All connections in the FTP connection pool are disconnected. It is not an abrupt disconnection -- Parameters:
callback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-
disconnectAsync
public DisconnectResult disconnectAsync(boolean immediate, AsyncCallback.Disconnect callback, Object tag) throws FTPException Disconnect from the FTP server asynchronously. All connections in the FTP connection pool are disconnected.- Parameters:
immediate- if set to true, immediately kills connectionscallback- callback to be notified when connection is completedtag- any object reference can be saved in this tag and can be accessed later from the result object (e.g. in the callback).- Returns:
- result object
- Throws:
FTPException
-