public class SecureFileTransferClient extends java.lang.Object implements FileTransferClientInterface
Multiple protocols are supported, including 'plain' FTP, SFTP (FTP over SSH), and FTPS (FTP over SSL - both implicit and explicit modes). The protocol can be changed with a single method call.
A simple example is shown below:
SecureFileTransferClient client = new SecureFileTransferClient(); client.setRemoteHost(host); client.setUserName(user); client.setPassword(password); client.setProtocol(Protocol.FTP); // FTP is the default // connect client.connect(); // perform a transfer, uploading the local file as 'remote.txt' client.uploadFile("local.txt", "remote.txt"); // disconnect from server client.disconnect();
Users should note that calling connect() starts a pool of worker threads and the connection pool. This means that disconnect() must be called to stop the worker threads, otherwise applications will hang on exit as threads will still be alive.
Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap |
activeTransferTasks
Active transfer tasks, hashed on id
|
protected AdvancedFTPSettings |
advancedFTPSettings
Advanced configuration parameters that often aren't used
|
protected AdvancedGeneralSettings |
advancedSettings |
protected AdvancedSSHSettings |
advancedSSHSettings |
protected AdvancedSSLSettings |
advancedSSLSettings |
protected com.enterprisedt.net.ftp.async.internal.AsyncFileTransferClientImpl |
asyncImpl |
protected EventListener |
eventListener
Notifies of various events
|
protected com.enterprisedt.net.ftp.async.internal.SecureConnectionContext |
masterContext
Connection context
|
protected MultipleTransferSettings |
multiSettings |
protected ProxySettings |
proxySettings |
Constructor and Description |
---|
SecureFileTransferClient()
Constructor.
|
SecureFileTransferClient(int initialPoolSize,
int maxPoolSize)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addErrorListener(ErrorListener listener)
Add an error listener to the list of listeners
|
void |
cancelAllTransfers()
Cancel all transfers that are either pending or currently under way
|
void |
changeDirectory(java.lang.String directoryName)
Change directory on the FTP server.
|
boolean |
changeIntoPathDirectory()
If true (the default), when paths are supplied as part of filenames,
the directory is changed into before transferring the file,e.g.
|
void |
changeToParentDirectory()
Change to parent directory on the FTP server.
|
protected void |
checkConnection(boolean shouldBeConnected)
Checks if the client has connected to the server and throws an exception if it hasn't.
|
void |
connect()
Make a connection to the FTP server.
|
void |
createDirectory(java.lang.String directoryName)
Create directory on the FTP server.
|
void |
deleteDirectory(java.lang.String directoryName)
Delete a directory on the FTP server.
|
void |
deleteDirectory(java.lang.String directoryName,
boolean recursive)
Delete a directory on the FTP server, and optionally sub-directories.
|
void |
deleteFile(java.lang.String remoteFileName)
Deletes a remote file.
|
void |
deleteMultipleFiles(java.io.FileFilter filter)
Deletes remote files in the current directory that
match the supplied filename filter
|
void |
deleteMultipleFiles(java.lang.String wildcard)
Deletes remote files in the current directory that
match the supplied wildcard
|
void |
deleteMultipleFiles(java.lang.String remoteDirectory,
java.io.FileFilter filter,
boolean recursive)
Deletes remote files in the current directory.
|
void |
deleteMultipleFiles(java.lang.String remoteDirectory,
java.lang.String wildcard,
boolean recursive)
Deletes remote files in the current directory.
|
FTPFile[] |
directoryList()
List the current directory on the FTP server.
|
FTPFile[] |
directoryList(java.lang.String directoryName)
List a directory on the FTP server.
|
void |
directoryList(java.lang.String directoryName,
DirectoryListCallback lister)
List a directory on the FTP server, calling the user-supplied callback for each entry.
|
java.lang.String[] |
directoryNameList()
List the names of files and directories in the current directory on the FTP server.
|
java.lang.String[] |
directoryNameList(java.lang.String directoryName,
boolean isLongListing)
List a directory on the FTP server.
|
void |
disconnect()
Disconnect from the FTP server.
|
void |
disconnect(boolean immediate)
Disconnect from the FTP server immediately.
|
byte[] |
downloadByteArray(java.lang.String remoteFileName)
Download a file from the FTP server into a byte array.
|
void |
downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
Download a file from the FTP server .
|
void |
downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
Download a file from the FTP server .
|
void |
downloadMultiple(java.lang.String localDir,
java.io.FileFilter filter)
Downloads remote files to the supplied local directory that match the supplied wildcard
from the current remote directory.
|
void |
downloadMultiple(java.lang.String localDir,
java.lang.String wildcard)
Downloads remote files to the supplied local directory that match the supplied wildcard
from the current remote directory.
|
void |
downloadMultiple(java.lang.String localDir,
java.lang.String remoteDir,
java.io.FileFilter filter,
boolean recursive)
Downloads remote files to the supplied local directory that match the supplied FileFilter
from the current remote directory.
|
void |
downloadMultiple(java.lang.String localDir,
java.lang.String remoteDir,
java.lang.String wildcard,
boolean recursive)
Downloads remote files to the supplied local directory that match the supplied wildcard
from the current remote directory.
|
FileTransferInputStream |
downloadStream(java.lang.String remoteFileName)
Download a file from the FTP server as a stream.
|
static void |
downloadURLFile(java.lang.String localFileName,
java.lang.String ftpURL)
Downloads the given file to the given FTP URL.
|
static FileTransferInputStream |
downloadURLStream(java.lang.String ftpURL)
Open an InputStream for the given FTP URL.
|
java.lang.String |
executeCommand(java.lang.String command)
Request that the remote server execute the literal command supplied.
|
boolean |
exists(java.lang.String remoteFileName)
Determine if a remote file exists.
|
boolean |
existsDirectory(java.lang.String remoteDir)
Determine if a remote directory exists.
|
void |
finalize()
Finalize this instance by shutting down its threads
|
AdvancedFTPSettings |
getAdvancedFTPSettings()
Get the advanced FTP configuration parameters object
|
AdvancedGeneralSettings |
getAdvancedSettings()
Get the advanced general configuration parameters object, for none
protocol specific parameters
|
AdvancedSSHSettings |
getAdvancedSSHSettings()
Get the advanced SSH configuration parameters object
|
AdvancedSSLSettings |
getAdvancedSSLSettings()
Get the advanced SSL configuration parameters object
|
FTPTransferType |
getContentType()
Get the current content type for all connections.
|
java.lang.String |
getInitialRemoteDirectory()
Returns the initial remote directory that all connections change to
immediately on connection.
|
FTPReply |
getLastReply()
Gets the last FTP reply from the server, whether valid or not.
|
int |
getMaxTransferRate()
Get the maximum bandwidth for transfers
|
java.util.Date |
getModifiedTime(java.lang.String remoteFileName)
Get the modified-time of a remote file.
|
MultipleTransferSettings |
getMultipleTransferSettings()
Get the configuration object that controls the settings used for
multiple transfers
|
int |
getNetworkBufferSize()
Get the size of the network buffers (SO_SNDBUF
and SO_RCVBUF).
|
java.lang.String |
getPassword()
Get the current user password.
|
Protocol |
getProtocol()
Get the current protocol being used
|
ProxySettings |
getProxySettings()
Get the proxy settings instance.
|
java.lang.String |
getRemoteDirectory()
Get the current remote directory of the master context.
|
java.lang.String |
getRemoteHost()
Returns the IP address or name of the remote host.
|
int |
getRemotePort()
Returns the port being connected to on the remote server.
|
long |
getSize(java.lang.String remoteFileName)
Get the size of a remote file.
|
FileStatistics |
getStatistics()
Get statistics on file transfers and deletions.
|
java.lang.String |
getSystemType()
Get a string that represents the remote system that the client is logged
into.
|
int |
getTimeout()
Returns the timeout for socket connections.
|
java.lang.String |
getUserName()
Get the current user name.
|
boolean |
isCompressionPreferred()
Is compression enabled?
|
boolean |
isConnected()
Is this client currently connected to the server?
|
boolean |
isDetectContentType()
Get the detect content type flag
|
boolean |
isKeepAliveEnabled()
Is the connection pool's keep alive thread enabled, i.e.
|
boolean |
isServerValidationEnabled()
Is server validation switched on, i.e.
|
boolean |
isTransferIntegrityCheck()
Is integrity checking of transfers enabled?
|
void |
loadSSHServerValidation(java.lang.String knownHosts)
Load the public keys that the server public key will be validated
against.
|
void |
loadSSLServerValidation(java.lang.String rootCertificatesPath)
Load the root certificates that the server certificate will be validated
against.
|
void |
rename(java.lang.String renameFromName,
java.lang.String renameToName)
Rename a remote file or directory.
|
void |
setChangeIntoPathDirectory(boolean changeIntoPathDirectory)
Determine if when a path is supplied as part of a filename,
whether the directory is changed into before transferring the file, e.g.
|
void |
setCompressionPreferred(boolean enabled)
Set compression flag on or off.
|
void |
setContentType(FTPTransferType type)
Set the transfer type for all connections, either ASCII or binary.
|
void |
setDetectContentType(boolean detectContentType)
Set auto detect of filetypes on or off.
|
void |
setEventListener(EventListener listener)
Set the event listener for transfer event notification
|
void |
setInitialRemoteDirectory(java.lang.String directory)
Set the initial remote directory that all connections change to
immediately on connection.
|
void |
setKeepAliveEnabled(boolean enabled)
Change the connection pool keep alive setting, switching it on or off.
|
void |
setMaxTransferRate(int thresholdBytesPerSecond)
Set the maximum transfer rates in bytes per sec
|
void |
setModifiedTime(java.lang.String remoteFileName,
java.util.Date modifiedTime)
Set the modified-time of a remote file.
|
void |
setNetworkBufferSize(int networkBufferSize)
Set the size of the network buffers (SO_SNDBUF
and SO_RCVBUF).
|
void |
setPassword(java.lang.String password)
Set the password of the user to log in with.
|
void |
setPermissions(java.lang.String remotePath,
int permissions)
Set the permissions of the supplied file or directory.
|
void |
setProtocol(Protocol protocol)
Set the current protocol to be used.
|
void |
setRemoteHost(java.lang.String remoteHost)
Set the IP address or name of the remote host
This may only be done if the client is not already connected to the server.
|
void |
setRemotePort(int remotePort)
Set the port to connect to on the remote server.
|
void |
setServerValidationEnabled(boolean enabled)
Change the server validation setting, switching it on or off.
|
void |
setTimeout(int timeout)
Set the timeout for socket connections.
|
void |
setTransferIntegrityCheck(boolean enabled)
Enable or disable integrity checks on transfers.
|
void |
setUserName(java.lang.String userName)
Set the name of the user to log in with.
|
protected void |
shutdown(boolean immediate)
Shutdown all the worker threads in the task processor.
|
java.lang.String |
uploadByteArray(byte[] bytes,
java.lang.String remoteFileName,
WriteMode writeMode)
Upload a byte array to the FTP server.
|
java.lang.String |
uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
Upload a file to the FTP server.
|
java.lang.String |
uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
Upload a file to the FTP server.
|
void |
uploadMultiple(java.lang.String localDir,
java.io.FileFilter filter)
Uploads local files from the supplied local directory that match the supplied FileFilter
into the current remote directory.
|
void |
uploadMultiple(java.lang.String localDir,
java.lang.String wildcard)
Uploads local files from the supplied local directory that match the supplied wildcard
into the current remote directory.
|
void |
uploadMultiple(java.lang.String localDir,
java.lang.String remoteDir,
java.io.FileFilter filter,
boolean recursive)
Uploads local files from the supplied local directory that match the supplied wildcard
into the supplied remote directory.
|
void |
uploadMultiple(java.lang.String localDir,
java.lang.String remoteDir,
java.lang.String wildcard,
boolean recursive)
Uploads local files from the supplied local directory that match the supplied wildcard
into the supplied remote directory.
|
FileTransferOutputStream |
uploadStream(java.lang.String remoteFileName)
Upload a file to the FTP server by writing to a stream.
|
FileTransferOutputStream |
uploadStream(java.lang.String remoteFileName,
WriteMode writeMode)
Upload a file to the FTP server by writing to a stream.
|
static void |
uploadURLFile(java.lang.String localFileName,
java.lang.String ftpURL)
Uploads the given file to the given FTP URL.
|
static FileTransferOutputStream |
uploadURLStream(java.lang.String ftpURL)
Open an OutputStream for the given FTP URL.
|
protected com.enterprisedt.net.ftp.async.internal.AsyncFileTransferClientImpl asyncImpl
protected com.enterprisedt.net.ftp.async.internal.SecureConnectionContext masterContext
protected java.util.HashMap activeTransferTasks
protected EventListener eventListener
protected MultipleTransferSettings multiSettings
protected ProxySettings proxySettings
protected AdvancedFTPSettings advancedFTPSettings
protected AdvancedGeneralSettings advancedSettings
protected AdvancedSSLSettings advancedSSLSettings
protected AdvancedSSHSettings advancedSSHSettings
public SecureFileTransferClient(int initialPoolSize, int maxPoolSize)
initialPoolSize
- initial size of connection pool (i.e. number of managed connections).maxPoolSize
- maximum size of pool.public SecureFileTransferClient()
protected void checkConnection(boolean shouldBeConnected) throws FTPException
FTPException
- Thrown if the client has not connected to the server.public java.lang.String getRemoteHost()
getRemoteHost
in interface FileTransferClientInterface
public void setRemoteHost(java.lang.String remoteHost) throws FTPException
setRemoteHost
in interface FileTransferClientInterface
remoteHost
- The IP address or name of the remote hostFTPException
- Thrown if the client is already connected to the server.public Protocol getProtocol()
public void setProtocol(Protocol protocol) throws FTPException
protocol
- protocol to useFTPException
public ProxySettings getProxySettings()
public int getTimeout()
getTimeout
in interface FileTransferClientInterface
public void setTimeout(int timeout) throws FTPException
setTimeout
in interface FileTransferClientInterface
timeout
- the timeout to use in millisecondsFTPException
- Thrown if the client is already connected to the server.public int getNetworkBufferSize()
getNetworkBufferSize
in interface FileTransferClientInterface
public void setNetworkBufferSize(int networkBufferSize) throws FTPException
setNetworkBufferSize
in interface FileTransferClientInterface
networkBufferSize
- new buffer size to setFTPException
public int getRemotePort()
getRemotePort
in interface FileTransferClientInterface
public void setRemotePort(int remotePort) throws FTPException
setRemotePort
in interface FileTransferClientInterface
remotePort
- The port to use.FTPException
- Thrown if the client is already connected to the server.public void setContentType(FTPTransferType type) throws java.io.IOException, FTPException
setContentType
in interface FileTransferClientInterface
type
- transfer typejava.io.IOException
FTPException
public FTPTransferType getContentType()
getContentType
in interface FileTransferClientInterface
public void setDetectContentType(boolean detectContentType)
setDetectContentType
in interface FileTransferClientInterface
detectContentType
- true if detecting content type, false if notpublic boolean isDetectContentType()
isDetectContentType
in interface FileTransferClientInterface
public void setUserName(java.lang.String userName) throws FTPException
setUserName
in interface FileTransferClientInterface
userName
- user-name to log in with.FTPException
public java.lang.String getPassword()
getPassword
in interface FileTransferClientInterface
public void setPassword(java.lang.String password) throws FTPException
setPassword
in interface FileTransferClientInterface
password
- password to log in with.FTPException
public java.lang.String getUserName()
getUserName
in interface FileTransferClientInterface
public void setMaxTransferRate(int thresholdBytesPerSecond)
thresholdBytesPerSecond
- maximum bytes per second to transferpublic int getMaxTransferRate()
public boolean isTransferIntegrityCheck()
public void setTransferIntegrityCheck(boolean enabled)
enabled
- true if enabled, false otherwisepublic boolean isCompressionPreferred()
public void setCompressionPreferred(boolean enabled)
enabled
- true to enable, false to disable.public AdvancedFTPSettings getAdvancedFTPSettings()
getAdvancedFTPSettings
in interface FileTransferClientInterface
public AdvancedGeneralSettings getAdvancedSettings()
getAdvancedSettings
in interface FileTransferClientInterface
public AdvancedSSLSettings getAdvancedSSLSettings()
public AdvancedSSHSettings getAdvancedSSHSettings()
public MultipleTransferSettings getMultipleTransferSettings()
public boolean changeIntoPathDirectory()
public void setChangeIntoPathDirectory(boolean changeIntoPathDirectory)
changeIntoPathDirectory
- set whether or not the client should change into
the path suppliedpublic boolean isServerValidationEnabled()
public void setServerValidationEnabled(boolean enabled) throws FTPException
enabled
- true to enable, false to disableFTPException
public boolean isKeepAliveEnabled()
public void setKeepAliveEnabled(boolean enabled) throws FTPException
enabled
- true to enable, false to disableFTPException
public void loadSSLServerValidation(java.lang.String rootCertificatesPath) throws java.io.FileNotFoundException, java.io.IOException, FTPException
rootCertificatesPath
- path to root certificatesjava.io.FileNotFoundException
java.io.IOException
FTPException
public void loadSSHServerValidation(java.lang.String knownHosts) throws java.io.FileNotFoundException, java.io.IOException, FTPException
knownHosts
- path to known hosts filejava.io.FileNotFoundException
java.io.IOException
FTPException
public boolean isConnected()
isConnected
in interface FileTransferClientInterface
public java.lang.String getInitialRemoteDirectory()
public void setInitialRemoteDirectory(java.lang.String directory) throws FTPException
directory
- The initial remote directoryFTPException
- Thrown if the client is already connected to the server.public java.lang.String getRemoteDirectory()
getRemoteDirectory
in interface FileTransferClientInterface
public void setEventListener(EventListener listener)
setEventListener
in interface FileTransferClientInterface
listener
- event listener referencepublic FileStatistics getStatistics()
getStatistics
in interface FileTransferClientInterface
public void connect() throws FTPException, java.io.IOException
connect
in interface FileTransferClientInterface
FTPException
java.io.IOException
public java.lang.String executeCommand(java.lang.String command) throws FTPException, java.io.IOException
It is up to the user to send a sensible command.
executeCommand
in interface FileTransferClientInterface
command
- command stringFTPException
java.io.IOException
public FTPReply getLastReply()
public java.lang.String getSystemType() throws FTPException, java.io.IOException
getSystemType
in interface FileTransferClientInterface
FTPException
java.io.IOException
public java.lang.String[] directoryNameList() throws FTPException, java.io.IOException
directoryNameList
in interface FileTransferClientInterface
FTPException
java.io.IOException
public java.lang.String[] directoryNameList(java.lang.String directoryName, boolean isLongListing) throws FTPException, java.io.IOException
directoryNameList
in interface FileTransferClientInterface
directoryName
- name of the directory (generally not a path)isLongListing
- true if the listing is a long format listingFTPException
java.io.IOException
public FTPFile[] directoryList() throws FTPException, java.io.IOException, java.text.ParseException
directoryList
in interface FileTransferClientInterface
java.text.ParseException
FTPException
java.io.IOException
public void directoryList(java.lang.String directoryName, DirectoryListCallback lister) throws FTPException, java.io.IOException
directoryList
in interface FileTransferClientInterface
directoryName
- name of the directory (generally not a path)FTPException
java.io.IOException
public FTPFile[] directoryList(java.lang.String directoryName) throws FTPException, java.io.IOException
directoryList
in interface FileTransferClientInterface
directoryName
- name of the directory (generally not a path)FTPException
java.io.IOException
public byte[] downloadByteArray(java.lang.String remoteFileName) throws FTPException, java.io.IOException
downloadByteArray
in interface FileTransferClientInterface
remoteFileName
- name of the remote file to be downloadedFTPException
java.io.IOException
public void downloadFile(java.lang.String localFileName, java.lang.String remoteFileName) throws FTPException, java.io.IOException
downloadFile
in interface FileTransferClientInterface
localFileName
- name (or full path) of the local file to be downloaded toremoteFileName
- name of the remote file to be downloadedFTPException
java.io.IOException
public void downloadFile(java.lang.String localFileName, java.lang.String remoteFileName, WriteMode writeMode) throws FTPException, java.io.IOException
downloadFile
in interface FileTransferClientInterface
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 client machineFTPException
java.io.IOException
public FileTransferInputStream downloadStream(java.lang.String remoteFileName) throws FTPException, java.io.IOException
downloadStream
in interface FileTransferClientInterface
remoteFileName
- name of the remote file to be downloadedFTPException
java.io.IOException
public static FileTransferInputStream downloadURLStream(java.lang.String ftpURL) throws java.net.MalformedURLException, java.io.IOException, FTPException
(protocol)://[user[:password]@]host[:port]/path
.
The value of 'protocol' may be ftp for plain FTP; sftp for SFTP;
ftps, ftpes or ftpse for explicit FTPS; or
ftpis or ftpsi for implicit FTPS.
The stream should be closed when
the transfer is complete.ftpURL
- The URL must be of the form (protocol)://[user[:password]@]host[:port]/path
.java.net.MalformedURLException
- Thrown when an invalid URL is provided.java.io.IOException
- Thrown when an I/O-related error occurs.FTPException
- Thrown when an FTP-protocol-related error occurs.public static void downloadURLFile(java.lang.String localFileName, java.lang.String ftpURL) throws java.net.MalformedURLException, java.io.IOException, FTPException
(protocol)://[user[:password]@]host[:port]/path
.
The value of 'protocol' may be ftp for plain FTP; sftp for SFTP;
ftps, ftpes or ftpse for explicit FTPS; or
ftpis or ftpsi for implicit FTPS.localFileName
- Path to local fileftpURL
- The URL must be of the form (protocol)://[user[:password]@]host[:port]/path
.java.net.MalformedURLException
- Thrown when an invalid URL is provided.java.io.IOException
- Thrown when an I/O-related error occurs.FTPException
- Thrown when an FTP-protocol-related error occurs.public java.lang.String uploadFile(java.lang.String localFileName, java.lang.String remoteFileName) throws FTPException, java.io.IOException
uploadFile
in interface FileTransferClientInterface
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)append
- true if in append modeFTPException
java.io.IOException
public java.lang.String uploadFile(java.lang.String localFileName, java.lang.String remoteFileName, WriteMode writeMode) throws FTPException, java.io.IOException
uploadFile
in interface FileTransferClientInterface
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 to write to the remote file withFTPException
java.io.IOException
public java.lang.String uploadByteArray(byte[] bytes, java.lang.String remoteFileName, WriteMode writeMode) throws FTPException, java.io.IOException
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).FTPException
java.io.IOException
public FileTransferOutputStream uploadStream(java.lang.String remoteFileName) throws FTPException
FileTransferOutputStream#getRemoteFileName()
uploadStream
in interface FileTransferClientInterface
remoteFileName
- name of the remote file to be uploadedFTPException
public FileTransferOutputStream uploadStream(java.lang.String remoteFileName, WriteMode writeMode) throws FTPException
FileTransferOutputStream#getRemoteFileName()
uploadStream
in interface FileTransferClientInterface
remoteFileName
- name of the remote file to be uploadedwriteMode
- mode in which the file is written to the serverFTPException
public static FileTransferOutputStream uploadURLStream(java.lang.String ftpURL) throws java.net.MalformedURLException, java.io.IOException, FTPException
(protocol)://[user[:password]@]host[:port]/path
. The value
of 'protocol' may be ftp for plain FTP; sftp for SFTP;
ftps, ftpes or ftpse for explicit FTPS; or
ftpis or ftpsi for implicit FTPS. The stream must be closed
when the transfer is complete.ftpURL
- The URL must be of the form (protocol)://[user[:password]@]host[:port]/path
.java.net.MalformedURLException
- Thrown when an invalid URL is provided.java.io.IOException
- Thrown when an I/O-related error occurs.FTPException
- Thrown when an FTP-protocol-related error occurs.public static void uploadURLFile(java.lang.String localFileName, java.lang.String ftpURL) throws java.net.MalformedURLException, java.io.IOException, FTPException
(protocol)://[user[:password]@]host[:port]/path
.
The value of 'protocol' may be ftp for plain FTP; sftp for SFTP;
ftps, ftpes or ftpse for explicit FTPS; or
ftpis or ftpsi for implicit FTPS.localFileName
- Path to local fileftpURL
- The URL must be of the form (protocol)://[user[:password]@]host[:port]/path
.java.net.MalformedURLException
- Thrown when an invalid URL is provided.java.io.IOException
- Thrown when an I/O-related error occurs.FTPException
- Thrown when an FTP-protocol-related error occurs.public long getSize(java.lang.String remoteFileName) throws FTPException, java.io.IOException
getSize
in interface FileTransferClientInterface
remoteFileName
- name of remote fileFTPException
java.io.IOException
public java.util.Date getModifiedTime(java.lang.String remoteFileName) throws FTPException, java.io.IOException
getModifiedTime
in interface FileTransferClientInterface
remoteFileName
- name of remote fileFTPException
java.io.IOException
public void setModifiedTime(java.lang.String remoteFileName, java.util.Date modifiedTime) throws FTPException, java.io.IOException
setModifiedTime
in interface FileTransferClientInterface
remoteFileName
- name of remote filemodifiedTime
- new modified timeFTPException
java.io.IOException
public void setPermissions(java.lang.String remotePath, int permissions) throws FTPException, java.io.IOException
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
remotePath
- path of file or directorypermissions
- octal permissions (must be preceded with a '0').FTPException
java.io.IOException
public boolean exists(java.lang.String remoteFileName) throws FTPException, java.io.IOException
exists
in interface FileTransferClientInterface
remoteFileName
- name of remote fileFTPException
java.io.IOException
public boolean existsDirectory(java.lang.String remoteDir) throws FTPException, java.io.IOException
remoteDir
- name of remote directoryFTPException
java.io.IOException
public void deleteFile(java.lang.String remoteFileName) throws FTPException, java.io.IOException
deleteFile
in interface FileTransferClientInterface
remoteFileName
- name of remote fileFTPException
java.io.IOException
public void deleteMultipleFiles(java.lang.String wildcard) throws FTPException, java.io.IOException
wildcard
- wildcard string (supporting '*' and '?')FTPException
java.io.IOException
public void deleteMultipleFiles(java.io.FileFilter filter) throws FTPException, java.io.IOException
wildcard
- filename filterFTPException
java.io.IOException
public void deleteMultipleFiles(java.lang.String remoteDirectory, java.lang.String wildcard, boolean recursive) throws FTPException, java.io.IOException
remoteFileName
- name of remote fileFTPException
java.io.IOException
public void deleteMultipleFiles(java.lang.String remoteDirectory, java.io.FileFilter filter, boolean recursive) throws FTPException, java.io.IOException
remoteFileName
- name of remote fileFTPException
java.io.IOException
public void rename(java.lang.String renameFromName, java.lang.String renameToName) throws FTPException, java.io.IOException
rename
in interface FileTransferClientInterface
renameFromName
- original namerenameToName
- new nameFTPException
java.io.IOException
public void changeDirectory(java.lang.String directoryName) throws FTPException, java.io.IOException
changeDirectory
in interface FileTransferClientInterface
directoryName
- name the remote directory to change intoFTPException
java.io.IOException
public void changeToParentDirectory() throws FTPException, java.io.IOException
changeToParentDirectory
in interface FileTransferClientInterface
directoryName
- name the remote directory to change intoFTPException
java.io.IOException
public void createDirectory(java.lang.String directoryName) throws FTPException, java.io.IOException
createDirectory
in interface FileTransferClientInterface
directoryName
- name the remote directory to createFTPException
java.io.IOException
public void deleteDirectory(java.lang.String directoryName) throws FTPException, java.io.IOException
deleteDirectory
in interface FileTransferClientInterface
directoryName
- name the remote directory to createFTPException
java.io.IOException
public void deleteDirectory(java.lang.String directoryName, boolean recursive) throws FTPException, java.io.IOException
directoryName
- name the remote directory to createrecursive
- true if recursive deleteFTPException
java.io.IOException
public void uploadMultiple(java.lang.String localDir, java.io.FileFilter filter) throws FTPException, java.io.IOException
localDir
- name of local directoryfilter
- filename filterFTPException
java.io.IOException
public void uploadMultiple(java.lang.String localDir, java.lang.String wildcard) throws FTPException, java.io.IOException
localDir
- name of local directorywildcard
- wildcard filter for files to be uploaded (supports '*' and '?')FTPException
java.io.IOException
public void uploadMultiple(java.lang.String localDir, java.lang.String remoteDir, java.lang.String wildcard, boolean recursive) throws FTPException, java.io.IOException
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 subdirectoriesFTPException
java.io.IOException
public void uploadMultiple(java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter, boolean recursive) throws FTPException, java.io.IOException
localDir
- name of local directoryremoteDir
- name of remote directoryfilter
- filename filter for files to be uploadedrecursive
- if true, operation is recursive through sub-directoriesFTPException
java.io.IOException
public void downloadMultiple(java.lang.String localDir, java.io.FileFilter filter) throws FTPException, java.io.IOException
localDir
- name of local directoryfilter
- filename filterFTPException
java.io.IOException
public void downloadMultiple(java.lang.String localDir, java.lang.String wildcard) throws FTPException, java.io.IOException
localDir
- name of local directorywildcard
- wildcard filter for files to be uploaded (supports '*' and '?')FTPException
java.io.IOException
public void downloadMultiple(java.lang.String localDir, java.lang.String remoteDir, java.lang.String wildcard, boolean recursive) throws FTPException, java.io.IOException
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-directoriesFTPException
java.io.IOException
public void downloadMultiple(java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter, boolean recursive) throws FTPException, java.io.IOException
localDir
- name of local directoryremoteDir
- name of remote directoryfilter
- filename filter for files to be uploadedrecursive
- if true, operation is recursive through sub-directoriesFTPException
java.io.IOException
public void disconnect() throws FTPException, java.io.IOException
disconnect
in interface FileTransferClientInterface
FTPException
java.io.IOException
public void disconnect(boolean immediate) throws FTPException, java.io.IOException
disconnect
in interface FileTransferClientInterface
FTPException
java.io.IOException
public void addErrorListener(ErrorListener listener)
listener
- new error listenerprotected void shutdown(boolean immediate)
immediate
- if true, shutdown immediately, i.e. do not
wait for worker threads to terminatepublic void finalize()
finalize
in class java.lang.Object
public void cancelAllTransfers()
cancelAllTransfers
in interface FileTransferClientInterface
Copyright © 2001-2014 Enterprise Distributed Technologies Ltd. All Rights Reserved.