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 FileTransferClientInterfacepublic void setRemoteHost(java.lang.String remoteHost)
throws FTPException
setRemoteHost in interface FileTransferClientInterfaceremoteHost - 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 useFTPExceptionpublic ProxySettings getProxySettings()
public int getTimeout()
getTimeout in interface FileTransferClientInterfacepublic void setTimeout(int timeout)
throws FTPException
setTimeout in interface FileTransferClientInterfacetimeout - the timeout to use in millisecondsFTPException - Thrown if the client is already connected to the server.public int getNetworkBufferSize()
getNetworkBufferSize in interface FileTransferClientInterfacepublic void setNetworkBufferSize(int networkBufferSize)
throws FTPException
setNetworkBufferSize in interface FileTransferClientInterfacenetworkBufferSize - new buffer size to setFTPExceptionpublic int getRemotePort()
getRemotePort in interface FileTransferClientInterfacepublic void setRemotePort(int remotePort)
throws FTPException
setRemotePort in interface FileTransferClientInterfaceremotePort - 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 FileTransferClientInterfacetype - transfer typejava.io.IOExceptionFTPExceptionpublic FTPTransferType getContentType()
getContentType in interface FileTransferClientInterfacepublic void setDetectContentType(boolean detectContentType)
setDetectContentType in interface FileTransferClientInterfacedetectContentType - true if detecting content type, false if notpublic boolean isDetectContentType()
isDetectContentType in interface FileTransferClientInterfacepublic void setUserName(java.lang.String userName)
throws FTPException
setUserName in interface FileTransferClientInterfaceuserName - user-name to log in with.FTPExceptionpublic java.lang.String getPassword()
getPassword in interface FileTransferClientInterfacepublic void setPassword(java.lang.String password)
throws FTPException
setPassword in interface FileTransferClientInterfacepassword - password to log in with.FTPExceptionpublic java.lang.String getUserName()
getUserName in interface FileTransferClientInterfacepublic 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 FileTransferClientInterfacepublic AdvancedGeneralSettings getAdvancedSettings()
getAdvancedSettings in interface FileTransferClientInterfacepublic 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 disableFTPExceptionpublic boolean isKeepAliveEnabled()
public void setKeepAliveEnabled(boolean enabled)
throws FTPException
enabled - true to enable, false to disableFTPExceptionpublic void loadSSLServerValidation(java.lang.String rootCertificatesPath)
throws java.io.FileNotFoundException,
java.io.IOException,
FTPException
rootCertificatesPath - path to root certificatesjava.io.FileNotFoundExceptionjava.io.IOExceptionFTPExceptionpublic void loadSSHServerValidation(java.lang.String knownHosts)
throws java.io.FileNotFoundException,
java.io.IOException,
FTPException
knownHosts - path to known hosts filejava.io.FileNotFoundExceptionjava.io.IOExceptionFTPExceptionpublic boolean isConnected()
isConnected in interface FileTransferClientInterfacepublic 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 FileTransferClientInterfacepublic void setEventListener(EventListener listener)
setEventListener in interface FileTransferClientInterfacelistener - event listener referencepublic FileStatistics getStatistics()
getStatistics in interface FileTransferClientInterfacepublic void connect()
throws FTPException,
java.io.IOException
connect in interface FileTransferClientInterfaceFTPExceptionjava.io.IOExceptionpublic 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 FileTransferClientInterfacecommand - command stringFTPExceptionjava.io.IOExceptionpublic FTPReply getLastReply()
public java.lang.String getSystemType()
throws FTPException,
java.io.IOException
getSystemType in interface FileTransferClientInterfaceFTPExceptionjava.io.IOExceptionpublic java.lang.String[] directoryNameList()
throws FTPException,
java.io.IOException
directoryNameList in interface FileTransferClientInterfaceFTPExceptionjava.io.IOExceptionpublic java.lang.String[] directoryNameList(java.lang.String directoryName,
boolean isLongListing)
throws FTPException,
java.io.IOException
directoryNameList in interface FileTransferClientInterfacedirectoryName - name of the directory (generally not a path)isLongListing - true if the listing is a long format listingFTPExceptionjava.io.IOExceptionpublic FTPFile[] directoryList() throws FTPException, java.io.IOException, java.text.ParseException
directoryList in interface FileTransferClientInterfacejava.text.ParseExceptionFTPExceptionjava.io.IOExceptionpublic void directoryList(java.lang.String directoryName,
DirectoryListCallback lister)
throws FTPException,
java.io.IOException
directoryList in interface FileTransferClientInterfacedirectoryName - name of the directory (generally not a path)FTPExceptionjava.io.IOExceptionpublic FTPFile[] directoryList(java.lang.String directoryName) throws FTPException, java.io.IOException
directoryList in interface FileTransferClientInterfacedirectoryName - name of the directory (generally not a path)FTPExceptionjava.io.IOExceptionpublic byte[] downloadByteArray(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
downloadByteArray in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be downloadedFTPExceptionjava.io.IOExceptionpublic void downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
downloadFile in interface FileTransferClientInterfacelocalFileName - name (or full path) of the local file to be downloaded toremoteFileName - name of the remote file to be downloadedFTPExceptionjava.io.IOExceptionpublic void downloadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
throws FTPException,
java.io.IOException
downloadFile in interface FileTransferClientInterfacelocalFileName - 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 machineFTPExceptionjava.io.IOExceptionpublic FileTransferInputStream downloadStream(java.lang.String remoteFileName) throws FTPException, java.io.IOException
downloadStream in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be downloadedFTPExceptionjava.io.IOExceptionpublic 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 FileTransferClientInterfacelocalFileName - 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 modeFTPExceptionjava.io.IOExceptionpublic java.lang.String uploadFile(java.lang.String localFileName,
java.lang.String remoteFileName,
WriteMode writeMode)
throws FTPException,
java.io.IOException
uploadFile in interface FileTransferClientInterfacelocalFileName - 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 withFTPExceptionjava.io.IOExceptionpublic 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).FTPExceptionjava.io.IOExceptionpublic FileTransferOutputStream uploadStream(java.lang.String remoteFileName) throws FTPException
FileTransferOutputStream#getRemoteFileName()uploadStream in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be uploadedFTPExceptionpublic FileTransferOutputStream uploadStream(java.lang.String remoteFileName, WriteMode writeMode) throws FTPException
FileTransferOutputStream#getRemoteFileName()uploadStream in interface FileTransferClientInterfaceremoteFileName - name of the remote file to be uploadedwriteMode - mode in which the file is written to the serverFTPExceptionpublic 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 FileTransferClientInterfaceremoteFileName - name of remote fileFTPExceptionjava.io.IOExceptionpublic java.util.Date getModifiedTime(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
getModifiedTime in interface FileTransferClientInterfaceremoteFileName - name of remote fileFTPExceptionjava.io.IOExceptionpublic void setModifiedTime(java.lang.String remoteFileName,
java.util.Date modifiedTime)
throws FTPException,
java.io.IOException
setModifiedTime in interface FileTransferClientInterfaceremoteFileName - name of remote filemodifiedTime - new modified timeFTPExceptionjava.io.IOExceptionpublic 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').FTPExceptionjava.io.IOExceptionpublic boolean exists(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
exists in interface FileTransferClientInterfaceremoteFileName - name of remote fileFTPExceptionjava.io.IOExceptionpublic boolean existsDirectory(java.lang.String remoteDir)
throws FTPException,
java.io.IOException
remoteDir - name of remote directoryFTPExceptionjava.io.IOExceptionpublic void deleteFile(java.lang.String remoteFileName)
throws FTPException,
java.io.IOException
deleteFile in interface FileTransferClientInterfaceremoteFileName - name of remote fileFTPExceptionjava.io.IOExceptionpublic void deleteMultipleFiles(java.lang.String wildcard)
throws FTPException,
java.io.IOException
wildcard - wildcard string (supporting '*' and '?')FTPExceptionjava.io.IOExceptionpublic void deleteMultipleFiles(java.io.FileFilter filter)
throws FTPException,
java.io.IOException
wildcard - filename filterFTPExceptionjava.io.IOExceptionpublic void deleteMultipleFiles(java.lang.String remoteDirectory,
java.lang.String wildcard,
boolean recursive)
throws FTPException,
java.io.IOException
remoteFileName - name of remote fileFTPExceptionjava.io.IOExceptionpublic void deleteMultipleFiles(java.lang.String remoteDirectory,
java.io.FileFilter filter,
boolean recursive)
throws FTPException,
java.io.IOException
remoteFileName - name of remote fileFTPExceptionjava.io.IOExceptionpublic void rename(java.lang.String renameFromName,
java.lang.String renameToName)
throws FTPException,
java.io.IOException
rename in interface FileTransferClientInterfacerenameFromName - original namerenameToName - new nameFTPExceptionjava.io.IOExceptionpublic void changeDirectory(java.lang.String directoryName)
throws FTPException,
java.io.IOException
changeDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to change intoFTPExceptionjava.io.IOExceptionpublic void changeToParentDirectory()
throws FTPException,
java.io.IOException
changeToParentDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to change intoFTPExceptionjava.io.IOExceptionpublic void createDirectory(java.lang.String directoryName)
throws FTPException,
java.io.IOException
createDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to createFTPExceptionjava.io.IOExceptionpublic void deleteDirectory(java.lang.String directoryName)
throws FTPException,
java.io.IOException
deleteDirectory in interface FileTransferClientInterfacedirectoryName - name the remote directory to createFTPExceptionjava.io.IOExceptionpublic void deleteDirectory(java.lang.String directoryName,
boolean recursive)
throws FTPException,
java.io.IOException
directoryName - name the remote directory to createrecursive - true if recursive deleteFTPExceptionjava.io.IOExceptionpublic void uploadMultiple(java.lang.String localDir,
java.io.FileFilter filter)
throws FTPException,
java.io.IOException
localDir - name of local directoryfilter - filename filterFTPExceptionjava.io.IOExceptionpublic 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 '?')FTPExceptionjava.io.IOExceptionpublic 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 subdirectoriesFTPExceptionjava.io.IOExceptionpublic 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-directoriesFTPExceptionjava.io.IOExceptionpublic void downloadMultiple(java.lang.String localDir,
java.io.FileFilter filter)
throws FTPException,
java.io.IOException
localDir - name of local directoryfilter - filename filterFTPExceptionjava.io.IOExceptionpublic 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 '?')FTPExceptionjava.io.IOExceptionpublic 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-directoriesFTPExceptionjava.io.IOExceptionpublic 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-directoriesFTPExceptionjava.io.IOExceptionpublic void disconnect()
throws FTPException,
java.io.IOException
disconnect in interface FileTransferClientInterfaceFTPExceptionjava.io.IOExceptionpublic void disconnect(boolean immediate)
throws FTPException,
java.io.IOException
disconnect in interface FileTransferClientInterfaceFTPExceptionjava.io.IOExceptionpublic 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.Objectpublic void cancelAllTransfers()
cancelAllTransfers in interface FileTransferClientInterfaceCopyright © 2001-2014 Enterprise Distributed Technologies Ltd. All Rights Reserved.