com.myjavaworld.ftp
Class DefaultFTPClient

java.lang.Object
  extended by com.myjavaworld.ftp.DefaultFTPClient
All Implemented Interfaces:
FTPClient, FTPConstants
Direct Known Subclasses:
AS400FTPClient

public class DefaultFTPClient
extends java.lang.Object
implements FTPClient, FTPConstants

The default implementation of FTPClient. Works well with most of the UNIX type FTP servers.

Version:
2.0
Author:
Sai Pullabhotla, psai [at] jMethods [dot] com

Field Summary
protected  int bufferSize
          Buffer size for transferring data over the network.
protected  boolean connected
          A flag that tells we are still connected to the remote host.
protected  ControlConnection controlConnection
          A Control Connection object for sending commands and receiving replies.
protected  boolean dataChannelUnencrypted
          A flag to determine if the data channel will be encrypted or not.
protected  DataConnection dataConnection
          A DataConnection object used for transferring data to/from the remote system.
protected  javax.swing.event.EventListenerList listenerList
          List of registered listeners.
protected  ListParser listParser
          A ListParser object used to parse the directory listing produced by the remote host.
protected  boolean loggedIn
          A flag that tells if we are logged in to the remote host.
protected  int mode
          Data transfer mode.
protected  boolean passive
          Whether or not to open data connections in passive mode.
protected  java.lang.String reply
          Stores that last reply received from the remote host.
protected  javax.net.ssl.SSLContext sslContext
          SSL context
protected  int sslUsage
          SSL usage of this ftp client.
protected  int structure
          Structure.
protected  int timeout
          Timeout for this FTPClient.
protected  int type
          Data representation type.
protected  RemoteFile workingDirectory
          Keep track of the current working directory on the remote host.
 
Fields inherited from interface com.myjavaworld.ftp.FTPConstants
DEFAULT_BUFFER_SIZE, DEFAULT_IMPLICIT_SSL_PORT, DEFAULT_MODE, DEFAULT_PORT, DEFAULT_STRUCTURE, DEFAULT_TIMEOUT, DEFAULT_TYPE, EOL, MODE_BLOCK, MODE_COMPRESSED, MODE_STREAM, STRUCTURE_FILE, STRUCTURE_PAGE, STRUCTURE_RECORD, TYPE_ASCII, TYPE_BINARY, TYPE_EBCDIC, TYPE_IMAGE, TYPE_LOCAL, USE_EXPLICIT_SSL, USE_IMPLICIT_SSL, USE_NO_SSL, USE_SSL_IF_AVAILABLE
 
Constructor Summary
DefaultFTPClient()
          Constructs an DefaultFTPClient object that is not connected to any host.
 
Method Summary
 void abort()
          Sends an abort command to the remote host.
 void addControlConnectionListener(ControlConnectionListener l)
          Adds a listener that will be notified about the activities of ControlConnection associated with this FTPClient .
 void addDataConnectionListener(DataConnectionListener l)
          Adds a DataConnection Listener to this FTPClient.
 void addFTPConnectionListener(FTPConnectionListener l)
          Adds the given FTPConnectionListener to the list of registered listeners.
 void allocate(long bytes)
          Allocates the specified number of bytes on the remote system.
 void close()
          Closes the control and data connections associated with this FTPClient.
 void connect(FTPHost ftpHost)
          Connects and logs in to the FTP host.
 void connect(java.lang.String host)
          Connects to the specified remote host host on the default FTP port.
 void connect(java.lang.String host, int port)
          Connects to the specfied remote host host, on the specified port number port.
 void createDirectory(RemoteFile dir)
          Creates the specified remote directory dir on the remote host.
 void createFile(RemoteFile file)
          Creates an empty file with the given name on the remote host.
 void delete(RemoteFile path)
          Deletes the specified path from the remote system.
 void deleteDirectory(RemoteFile dir)
          Deletes the specified directory dir on the remote system.
 void deleteFile(RemoteFile file)
          Deletes the specified file, file from the remote system.
 void disconnect()
          Sends a quit command to the remote system and closes the control connection and data connection associated with this FTPClient.
 void download(RemoteFile source, java.io.File destination, int type, boolean append)
          Copies the contents of the source to the local file destination.
 java.lang.String executeCommand(java.lang.String command)
          Executes the given command returns the response back.
protected  void fireConnectionClosed(FTPConnectionEvent evt)
          Fires the connection closed event to all registered listeners.
protected  void fireConnectionOpened(FTPConnectionEvent evt)
          Fires the ConnectionOpened event to all registered listeners.
 int getBufferSize()
          Returns the current buffer size being used by this FTPClient.
 java.lang.String getHelp()
          Executes the HELP command on the remote host and returns the response back.
 javax.swing.event.EventListenerList getListenerList()
          Returns the list of registered listeners.
 ListParser getListParser()
          Returns the current ListParser in use by this FTPClient.
 java.net.InetAddress getLocalAddress()
          Returns the InetAddress of the local host.
 java.lang.String getLocalHost()
          Returns the host name or IP address of the local host.
 java.lang.String getLocalIPAddress()
          Returns the IP address of the local host in xxx.xxx.xxx.xxx format.
 int getLocalPort()
          Returns the local port number used by the control connection.
 int getMode()
          Returns the current mode in use.
 java.net.InetAddress getRemoteAddress()
          Returns the Address of the remote host.
 java.lang.String getRemoteHost()
          Returns the fully qaulified domain name of the remote host.
 java.lang.String getRemoteIPAddress()
          Returns the IP address of the remote host in xxx.xxx.xxx.xxx format.
 int getRemotePort()
          Returns the remote port number to which the ControlConnection is established.
 javax.net.ssl.SSLContext getSSLContext()
          Gets the SSLContext of this FTPclient.
 int getSSLUsage()
          Returns the SSL usage of this FTPClient.
 int getStructure()
          Returns the current structure in use.
 java.lang.String getSystemInfo()
          Returns the remote host's information by executing the SYST command.
 int getTimeout()
          Returns the timeout setting of this FTP client.
 int getType()
          Returns the current data representation type in use.
 RemoteFile getWorkingDirectory()
          Returns the current working directory.
 boolean isConnected()
          Checks whether or not this FTPClient is still connected to to the remote host.
 boolean isDataChannelUnencrypted()
          Tells whether or not the data channel encryption is ON.
 boolean isLoggedIn()
          Checks wherher or not this client is logged in.
 boolean isPassive()
          Tells whether or not the data connectons are opned in passive mode.
 boolean isSecured()
          Tells whether this connection is secured.
 RemoteFile[] list()
          Retrieves the contents (children) of the current working directory.
 RemoteFile[] list(Filter filter)
          Retrieves the children of the current working directory.
 RemoteFile[] list(RemoteFile dir)
          Returns the direct children of the specified directory.
 RemoteFile[] list(RemoteFile dir, Filter filter)
          Returns the direct children of the specified directory.
 void login(java.lang.String user, java.lang.String password)
          Logs in to the remote host with the specified user id and password.
 void login(java.lang.String user, java.lang.String password, java.lang.String account)
          Logs in to the remote host with the specified user ID, pasword and account.
 void mountStructure(java.lang.String path)
          Sends a SMNT command with the specified path to mount.
 void noop()
          Sends a No-Operation command to the remote system.
 void reinitialize()
          Sends a reinitialize command to the remote host.
 void removeControlConnectionListener(ControlConnectionListener l)
          Removes the given listener from the list of registered listenerrs.
 void removeDataConnectionListener(DataConnectionListener l)
          Removes the given data connection listener from the registered list of listeners.
 void removeFTPConnectionListener(FTPConnectionListener l)
          Unregisters the given listener from the list of listeners.
 void rename(RemoteFile from, RemoteFile to)
          Renames a file or directory, from to to.
 void restart(long bytes)
          Sends a RESTART command to the remote host with the specified number of bytes.
 void setBufferSize(int bufferSize)
          Sets the buffer size to use for transferring data over the data connection.
 void setDataChannelUnencrypted(boolean dataChannelUnencrypted)
          Sets/unsets the flag to encrypt the data channel.
 void setListParser(ListParser listParser)
          Sets the ListParser to the specified listParser.ListParser objects are used to parsre the contents of a remote directory in to RemoteFile objects.
 void setMode(int mode)
          Sets the mode in which data is transferred to the given mode.
 void setPassive(boolean passive)
          If true, marks that the data is to be transgerrred over a passive data connection.
 void setSiteParameter(java.lang.String param)
          Sends a SITE command with the specified parameter(s).
 void setSSLContext(javax.net.ssl.SSLContext sslContext)
          Sets the SSLContext of this FTPClient to the given context.
 void setSSLUsage(int sslUsage)
          Sets the SSL usage of this client to the given value.
 void setStructure(int structure)
          Sets the structure to the specified structure.
 void setTimeout(int timeout)
          Sets the timeout for this FTPClient to the specified timeout.
 RemoteFile setToParentDirectory()
          Sets the remote working directory to the parent directory of the current working directory.
 void setType(int type)
          Sets the data representation type to the given type.
 RemoteFile setWorkingDirectory(RemoteFile dir)
          Sets the remote working directory to the specified directory dir.
 void upload(java.io.File source, RemoteFile destination, int type, boolean append, long skip)
          copies the contents of local file source to the specified remote file destination.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

timeout

protected int timeout
Timeout for this FTPClient.


bufferSize

protected int bufferSize
Buffer size for transferring data over the network.


type

protected int type
Data representation type. For e.g. ASCII, Binary etc.


mode

protected int mode
Data transfer mode. For e.g. Stream, Block etc.


structure

protected int structure
Structure. For e.g. File, Record, Page etc.


passive

protected boolean passive
Whether or not to open data connections in passive mode.


connected

protected boolean connected
A flag that tells we are still connected to the remote host.


loggedIn

protected boolean loggedIn
A flag that tells if we are logged in to the remote host.


workingDirectory

protected RemoteFile workingDirectory
Keep track of the current working directory on the remote host.


reply

protected java.lang.String reply
Stores that last reply received from the remote host.


controlConnection

protected ControlConnection controlConnection
A Control Connection object for sending commands and receiving replies.


dataConnection

protected DataConnection dataConnection
A DataConnection object used for transferring data to/from the remote system.


listParser

protected ListParser listParser
A ListParser object used to parse the directory listing produced by the remote host.


sslUsage

protected int sslUsage
SSL usage of this ftp client.


sslContext

protected javax.net.ssl.SSLContext sslContext
SSL context


dataChannelUnencrypted

protected boolean dataChannelUnencrypted
A flag to determine if the data channel will be encrypted or not.


listenerList

protected javax.swing.event.EventListenerList listenerList
List of registered listeners.

Constructor Detail

DefaultFTPClient

public DefaultFTPClient()
Constructs an DefaultFTPClient object that is not connected to any host.

Method Detail

setTimeout

public void setTimeout(int timeout)
Description copied from interface: FTPClient
Sets the timeout for this FTPClient to the specified timeout. Timeout is the amount of time an FTPClient waits for a server's reponse. If the server does not respond with in the timeout period, Implementations should close the connection. The timeout must be set before calling the connect methods. If an FTP client is already connected to a remote host, the new time out may be ignored by implementation classes.

Specified by:
setTimeout in interface FTPClient
Parameters:
timeout - Timeout in milli seconds.

getTimeout

public int getTimeout()
Description copied from interface: FTPClient
Returns the timeout setting of this FTP client.

Specified by:
getTimeout in interface FTPClient
Returns:
Timeout of this FTPClient.

setBufferSize

public void setBufferSize(int bufferSize)
Description copied from interface: FTPClient
Sets the buffer size to use for transferring data over the data connection.

Specified by:
setBufferSize in interface FTPClient
Parameters:
bufferSize - Buffer size to use for transferring data over the data connection.

getBufferSize

public int getBufferSize()
Description copied from interface: FTPClient
Returns the current buffer size being used by this FTPClient.

Specified by:
getBufferSize in interface FTPClient
Returns:
Current buffer size in use.

setListParser

public void setListParser(ListParser listParser)
Description copied from interface: FTPClient
Sets the ListParser to the specified listParser.ListParser objects are used to parsre the contents of a remote directory in to RemoteFile objects.

Specified by:
setListParser in interface FTPClient
Parameters:
listParser - The ListParser to use to parse the contents of a remote directory.

getListParser

public ListParser getListParser()
Description copied from interface: FTPClient
Returns the current ListParser in use by this FTPClient.

Specified by:
getListParser in interface FTPClient
Returns:
ListParser in use.

setSSLUsage

public void setSSLUsage(int sslUsage)
Description copied from interface: FTPClient
Sets the SSL usage of this client to the given value. The possible values are:

Specified by:
setSSLUsage in interface FTPClient
Parameters:
sslUsage - SSL usage parameter to set.

getSSLUsage

public int getSSLUsage()
Description copied from interface: FTPClient
Returns the SSL usage of this FTPClient.

Specified by:
getSSLUsage in interface FTPClient
Returns:
SSL usage of this FTPClient. Possible values are:
  • FTPConstants.USE_NO_SSL
  • FTPConstants.USE_SSL_IF_AVAILABLE
  • FTPConstants.USE_EXPLICIT_SSL
  • FTPConstants.USE_IMPLICIT_SSL

setSSLContext

public void setSSLContext(javax.net.ssl.SSLContext sslContext)
Description copied from interface: FTPClient
Sets the SSLContext of this FTPClient to the given context.

Specified by:
setSSLContext in interface FTPClient
Parameters:
sslContext - SSLContext

getSSLContext

public javax.net.ssl.SSLContext getSSLContext()
Description copied from interface: FTPClient
Gets the SSLContext of this FTPclient.

Specified by:
getSSLContext in interface FTPClient
Returns:
SSLContext of this FTPClient. May return null, if no context was set.

setDataChannelUnencrypted

public void setDataChannelUnencrypted(boolean dataChannelUnencrypted)
Description copied from interface: FTPClient
Sets/unsets the flag to encrypt the data channel.

Specified by:
setDataChannelUnencrypted in interface FTPClient
Parameters:
dataChannelUnencrypted - whether or not to encrypt the data channel.

isDataChannelUnencrypted

public boolean isDataChannelUnencrypted()
Description copied from interface: FTPClient
Tells whether or not the data channel encryption is ON.

Specified by:
isDataChannelUnencrypted in interface FTPClient
Returns:
true, if the data channel encryption os ON, false, otherwise.

isSecured

public boolean isSecured()
Description copied from interface: FTPClient
Tells whether this connection is secured.

Specified by:
isSecured in interface FTPClient
Returns:
true, if this connection is secured. false, othherwise.

connect

public void connect(java.lang.String host)
             throws FTPException,
                    ConnectionException
Description copied from interface: FTPClient
Connects to the specified remote host host on the default FTP port.

Specified by:
connect in interface FTPClient
Parameters:
host - Host name or IP address of the remote host.
Throws:
FTPException
ConnectionException

connect

public void connect(java.lang.String host,
                    int port)
             throws FTPException,
                    ConnectionException
Description copied from interface: FTPClient
Connects to the specfied remote host host, on the specified port number port.

Specified by:
connect in interface FTPClient
Parameters:
host - Host name or IP address of the remote host.
port - Port number to connect to.
Throws:
FTPException
ConnectionException

connect

public void connect(FTPHost ftpHost)
             throws FTPException,
                    ConnectionException
Description copied from interface: FTPClient
Connects and logs in to the FTP host.

Specified by:
connect in interface FTPClient
Parameters:
ftpHost - Remote FTP host to connect to.
Throws:
FTPException
ConnectionException

isConnected

public boolean isConnected()
Description copied from interface: FTPClient
Checks whether or not this FTPClient is still connected to to the remote host.

Specified by:
isConnected in interface FTPClient
Returns:
true, if this FTPClient is still connected to the remote host. Otherwise, false.

login

public void login(java.lang.String user,
                  java.lang.String password)
           throws FTPException,
                  ConnectionException
Description copied from interface: FTPClient
Logs in to the remote host with the specified user id and password.

Specified by:
login in interface FTPClient
Parameters:
user - User ID.
password - Password.
Throws:
FTPException
ConnectionException

login

public void login(java.lang.String user,
                  java.lang.String password,
                  java.lang.String account)
           throws FTPException,
                  ConnectionException
Description copied from interface: FTPClient
Logs in to the remote host with the specified user ID, pasword and account. Not all FTP servers need Account information.

Specified by:
login in interface FTPClient
Parameters:
user - User ID.
password - Password.
account - Account Name.
Throws:
FTPException
ConnectionException

isLoggedIn

public boolean isLoggedIn()
Description copied from interface: FTPClient
Checks wherher or not this client is logged in.

Specified by:
isLoggedIn in interface FTPClient
Returns:
true, if this client is logged in to the remote host. false otherwise.

setWorkingDirectory

public RemoteFile setWorkingDirectory(RemoteFile dir)
                               throws FTPException,
                                      ConnectionException
Description copied from interface: FTPClient
Sets the remote working directory to the specified directory dir. Clients must send a PWD command after sending the CWD command to make sure that the working directory has changed.

Specified by:
setWorkingDirectory in interface FTPClient
Parameters:
dir - New remote working directory to set.
Returns:
Working directory after the execution of this method.
Throws:
FTPException
ConnectionException

setToParentDirectory

public RemoteFile setToParentDirectory()
                                throws FTPException,
                                       ConnectionException
Description copied from interface: FTPClient
Sets the remote working directory to the parent directory of the current working directory.

Specified by:
setToParentDirectory in interface FTPClient
Returns:
working directory after the execution of this method.
Throws:
FTPException
ConnectionException

getWorkingDirectory

public RemoteFile getWorkingDirectory()
                               throws FTPException,
                                      ConnectionException
Description copied from interface: FTPClient
Returns the current working directory.

Specified by:
getWorkingDirectory in interface FTPClient
Returns:
Current remote working directory.
Throws:
FTPException
ConnectionException

setType

public void setType(int type)
             throws FTPException,
                    ConnectionException
Description copied from interface: FTPClient
Sets the data representation type to the given type.

Specified by:
setType in interface FTPClient
Parameters:
type - New data representation type to set. Possible types are -
  • FTPConstants.TYPE_ASCII
  • FTPConstants.TYPE_BINARY
  • FTPConstants.TYPE_IMAGE
  • FTPConstants.TYPE_EBCDIC
  • FTPConstants.TYPE_LOCAL
Throws:
FTPException
ConnectionException

getType

public int getType()
Description copied from interface: FTPClient
Returns the current data representation type in use.

Specified by:
getType in interface FTPClient
Returns:
current data representation type.

setStructure

public void setStructure(int structure)
                  throws FTPException,
                         ConnectionException
Description copied from interface: FTPClient
Sets the structure to the specified structure.

Specified by:
setStructure in interface FTPClient
Parameters:
structure - New structure to set. Possible structure type are -
  • FTPConstants.STRUCTURE_FILE
  • FTPConstants.STRUCTURE_RECORD
  • FTPConstants.STRUCTURE_PAGE
Throws:
FTPException
ConnectionException

getStructure

public int getStructure()
Description copied from interface: FTPClient
Returns the current structure in use.

Specified by:
getStructure in interface FTPClient
Returns:
current structure.

setMode

public void setMode(int mode)
             throws FTPException,
                    ConnectionException
Description copied from interface: FTPClient
Sets the mode in which data is transferred to the given mode.

Specified by:
setMode in interface FTPClient
Parameters:
mode - The new mode to set. Possible modes are -
  • FTPConstants.MODE_STREAM
  • FTPConstants.MODE_BLOCK
  • FTPConstants.MODE_COMPRESSED
Throws:
FTPException
ConnectionException

getMode

public int getMode()
Description copied from interface: FTPClient
Returns the current mode in use.

Specified by:
getMode in interface FTPClient
Returns:
Current mode in use.

setPassive

public void setPassive(boolean passive)
Description copied from interface: FTPClient
If true, marks that the data is to be transgerrred over a passive data connection.

Specified by:
setPassive in interface FTPClient
Parameters:
passive - Value true marks that the data is to be transferred over a passive data connection. Otherwise, over an active data connection.

isPassive

public boolean isPassive()
Description copied from interface: FTPClient
Tells whether or not the data connectons are opned in passive mode. This method will be consulted every time when there a need to open a data connection.

Specified by:
isPassive in interface FTPClient
Returns:
true if in passive mode. Otherwise, false.

createDirectory

public void createDirectory(RemoteFile dir)
                     throws FTPException,
                            ConnectionException
Description copied from interface: FTPClient
Creates the specified remote directory dir on the remote host.

Specified by:
createDirectory in interface FTPClient
Parameters:
dir - New directory to create.
Throws:
FTPException
ConnectionException

deleteDirectory

public void deleteDirectory(RemoteFile dir)
                     throws FTPException,
                            ConnectionException
Description copied from interface: FTPClient
Deletes the specified directory dir on the remote system. Most FTP servers would not allow the deletion of a directory unless it is empty. It is the responsibility of the clients to delete the children of the directory before attempting to delete a directory.

Specified by:
deleteDirectory in interface FTPClient
Parameters:
dir - Directory to delete.
Throws:
FTPException
ConnectionException

deleteFile

public void deleteFile(RemoteFile file)
                throws FTPException,
                       ConnectionException
Description copied from interface: FTPClient
Deletes the specified file, file from the remote system.

Specified by:
deleteFile in interface FTPClient
Parameters:
file - File to be deleted.
Throws:
FTPException
ConnectionException

delete

public void delete(RemoteFile path)
            throws FTPException,
                   ConnectionException
Description copied from interface: FTPClient
Deletes the specified path from the remote system. If the path is a directory (as determined by RemoteFile.isDirectory()) , then deleteDirectory() method will be called with path as an argument. Otherwise, deleteFile() method will be called with path as an argument.

Specified by:
delete in interface FTPClient
Parameters:
path - The file to delete.
Throws:
FTPException
ConnectionException

rename

public void rename(RemoteFile from,
                   RemoteFile to)
            throws FTPException,
                   ConnectionException
Description copied from interface: FTPClient
Renames a file or directory, from to to.

Specified by:
rename in interface FTPClient
Parameters:
from - The file to be renamed.
to - New file name.
Throws:
FTPException
ConnectionException

noop

public void noop()
          throws FTPException,
                 ConnectionException
Description copied from interface: FTPClient
Sends a No-Operation command to the remote system.

Specified by:
noop in interface FTPClient
Throws:
FTPException
ConnectionException

abort

public void abort()
           throws FTPException,
                  ConnectionException
Description copied from interface: FTPClient
Sends an abort command to the remote host.

Specified by:
abort in interface FTPClient
Throws:
FTPException
ConnectionException

reinitialize

public void reinitialize()
                  throws FTPException,
                         ConnectionException
Description copied from interface: FTPClient
Sends a reinitialize command to the remote host. Clients may need to login after executing this method.

Specified by:
reinitialize in interface FTPClient
Throws:
FTPException
ConnectionException

disconnect

public void disconnect()
                throws FTPException,
                       ConnectionException
Description copied from interface: FTPClient
Sends a quit command to the remote system and closes the control connection and data connection associated with this FTPClient.

Specified by:
disconnect in interface FTPClient
Throws:
FTPException
ConnectionException

close

public void close()
Description copied from interface: FTPClient
Closes the control and data connections associated with this FTPClient. This method should usually be called after a network error ocuurs in order to clean up the resources. Under normal conditions, the clients are recommended to call disconnect method.

Specified by:
close in interface FTPClient

allocate

public void allocate(long bytes)
              throws FTPException,
                     ConnectionException
Description copied from interface: FTPClient
Allocates the specified number of bytes on the remote system.

Specified by:
allocate in interface FTPClient
Parameters:
bytes - Number of bytes to allocate for this FTPClient.
Throws:
FTPException
ConnectionException

restart

public void restart(long bytes)
             throws FTPException,
                    ConnectionException
Description copied from interface: FTPClient
Sends a RESTART command to the remote host with the specified number of bytes.

Specified by:
restart in interface FTPClient
Parameters:
bytes - number of bytes to skip in the Input/Output stream.
Throws:
FTPException
ConnectionException

getSystemInfo

public java.lang.String getSystemInfo()
                               throws FTPException,
                                      ConnectionException
Description copied from interface: FTPClient
Returns the remote host's information by executing the SYST command.

Specified by:
getSystemInfo in interface FTPClient
Returns:
remote host's system information. The informaion returned will vary from FTP server to server.
Throws:
FTPException
ConnectionException

getHelp

public java.lang.String getHelp()
                         throws FTPException,
                                ConnectionException
Description copied from interface: FTPClient
Executes the HELP command on the remote host and returns the response back.

Specified by:
getHelp in interface FTPClient
Returns:
Response to HELP command.
Throws:
FTPException
ConnectionException

setSiteParameter

public void setSiteParameter(java.lang.String param)
                      throws FTPException,
                             ConnectionException
Description copied from interface: FTPClient
Sends a SITE command with the specified parameter(s).

Specified by:
setSiteParameter in interface FTPClient
Parameters:
param - Parameters or the SITE command.
Throws:
FTPException
ConnectionException

mountStructure

public void mountStructure(java.lang.String path)
                    throws FTPException,
                           ConnectionException
Description copied from interface: FTPClient
Sends a SMNT command with the specified path to mount.

Specified by:
mountStructure in interface FTPClient
Parameters:
path - New path structure to mount.
Throws:
FTPException
ConnectionException

executeCommand

public java.lang.String executeCommand(java.lang.String command)
                                throws FTPException,
                                       ConnectionException
Description copied from interface: FTPClient
Executes the given command returns the response back.

Specified by:
executeCommand in interface FTPClient
Parameters:
command - Command to execute.
Returns:
Response to the command sent.
Throws:
FTPException
ConnectionException

getRemoteAddress

public java.net.InetAddress getRemoteAddress()
Description copied from interface: FTPClient
Returns the Address of the remote host.

Specified by:
getRemoteAddress in interface FTPClient
Returns:
InetAddress of the remote host.

getRemoteHost

public java.lang.String getRemoteHost()
Description copied from interface: FTPClient
Returns the fully qaulified domain name of the remote host.

Specified by:
getRemoteHost in interface FTPClient
Returns:
domain name or IP address of the remote host.

getRemoteIPAddress

public java.lang.String getRemoteIPAddress()
Description copied from interface: FTPClient
Returns the IP address of the remote host in xxx.xxx.xxx.xxx format.

Specified by:
getRemoteIPAddress in interface FTPClient
Returns:
IP address of the remote host.

getRemotePort

public int getRemotePort()
Description copied from interface: FTPClient
Returns the remote port number to which the ControlConnection is established.

Specified by:
getRemotePort in interface FTPClient
Returns:
port number.

getLocalAddress

public java.net.InetAddress getLocalAddress()
Description copied from interface: FTPClient
Returns the InetAddress of the local host.

Specified by:
getLocalAddress in interface FTPClient
Returns:
InetAddress of the local host.

getLocalHost

public java.lang.String getLocalHost()
Description copied from interface: FTPClient
Returns the host name or IP address of the local host.

Specified by:
getLocalHost in interface FTPClient
Returns:
Host name or IP address of the local host.

getLocalIPAddress

public java.lang.String getLocalIPAddress()
Description copied from interface: FTPClient
Returns the IP address of the local host in xxx.xxx.xxx.xxx format.

Specified by:
getLocalIPAddress in interface FTPClient
Returns:
IP address of the local host.

getLocalPort

public int getLocalPort()
Description copied from interface: FTPClient
Returns the local port number used by the control connection.

Specified by:
getLocalPort in interface FTPClient
Returns:
Local port number.

list

public RemoteFile[] list()
                  throws FTPException,
                         java.text.ParseException,
                         ConnectionException
Description copied from interface: FTPClient
Retrieves the contents (children) of the current working directory.

Specified by:
list in interface FTPClient
Returns:
Direct children of the current working directory.
Throws:
FTPException
java.text.ParseException
ConnectionException

list

public RemoteFile[] list(Filter filter)
                  throws FTPException,
                         java.text.ParseException,
                         ConnectionException
Description copied from interface: FTPClient
Retrieves the children of the current working directory. The contents will be filtered using the given filter.

Specified by:
list in interface FTPClient
Parameters:
filter - the filter to use.
Returns:
direct children of the working directory.
Throws:
FTPException
java.text.ParseException
ConnectionException

list

public RemoteFile[] list(RemoteFile dir)
                  throws FTPException,
                         java.text.ParseException,
                         ConnectionException
Description copied from interface: FTPClient
Returns the direct children of the specified directory.

Specified by:
list in interface FTPClient
Parameters:
dir - directory whose children are to be retrieved
Returns:
Direct children of the specified directory dir.
Throws:
FTPException
java.text.ParseException
ConnectionException

list

public RemoteFile[] list(RemoteFile dir,
                         Filter filter)
                  throws FTPException,
                         java.text.ParseException,
                         ConnectionException
Description copied from interface: FTPClient
Returns the direct children of the specified directory.

Specified by:
list in interface FTPClient
Parameters:
dir - directory whose children are to be retrieved.
filter - Fiter to apply.
Returns:
Direct children of the given directory.
Throws:
FTPException
java.text.ParseException
ConnectionException

createFile

public void createFile(RemoteFile file)
                throws FTPException,
                       ConnectionException
Description copied from interface: FTPClient
Creates an empty file with the given name on the remote host.

Specified by:
createFile in interface FTPClient
Parameters:
file - Path and name of the file.
Throws:
FTPException
ConnectionException

download

public void download(RemoteFile source,
                     java.io.File destination,
                     int type,
                     boolean append)
              throws FTPException,
                     ConnectionException
Description copied from interface: FTPClient
Copies the contents of the source to the local file destination.

Specified by:
download in interface FTPClient
Parameters:
source - Remote file to be copied or downloaded.
destination - Local file to which the contents are to be copied.
type - Data representation type to use for data transfer.
append - Whether or not to open the destination file in append mode.
Throws:
FTPException
ConnectionException

upload

public void upload(java.io.File source,
                   RemoteFile destination,
                   int type,
                   boolean append,
                   long skip)
            throws FTPException,
                   ConnectionException
Description copied from interface: FTPClient
copies the contents of local file source to the specified remote file destination.

Specified by:
upload in interface FTPClient
Parameters:
source - Local file to be copied.
destination - Destination file on the remote system.
type - Data representation type to use for data transfer.
append - Whether or not the destination file is to be appended with the contents of source file.
skip - Number of bytes to skip.
Throws:
FTPException
ConnectionException

addControlConnectionListener

public void addControlConnectionListener(ControlConnectionListener l)
Description copied from interface: FTPClient
Adds a listener that will be notified about the activities of ControlConnection associated with this FTPClient .

Specified by:
addControlConnectionListener in interface FTPClient
Parameters:
l - Listener to register.

removeControlConnectionListener

public void removeControlConnectionListener(ControlConnectionListener l)
Description copied from interface: FTPClient
Removes the given listener from the list of registered listenerrs.

Specified by:
removeControlConnectionListener in interface FTPClient
Parameters:
l - Listner to remove from the registered listener list.

addDataConnectionListener

public void addDataConnectionListener(DataConnectionListener l)
Description copied from interface: FTPClient
Adds a DataConnection Listener to this FTPClient.

Specified by:
addDataConnectionListener in interface FTPClient
Parameters:
l - Listener to register.

removeDataConnectionListener

public void removeDataConnectionListener(DataConnectionListener l)
Description copied from interface: FTPClient
Removes the given data connection listener from the registered list of listeners.

Specified by:
removeDataConnectionListener in interface FTPClient
Parameters:
l - Listener to unregister.

getListenerList

public javax.swing.event.EventListenerList getListenerList()
Description copied from interface: FTPClient
Returns the list of registered listeners.

Specified by:
getListenerList in interface FTPClient
Returns:
List of registered listeners.

addFTPConnectionListener

public void addFTPConnectionListener(FTPConnectionListener l)
Description copied from interface: FTPClient
Adds the given FTPConnectionListener to the list of registered listeners.

Specified by:
addFTPConnectionListener in interface FTPClient
Parameters:
l - Listener to register.

removeFTPConnectionListener

public void removeFTPConnectionListener(FTPConnectionListener l)
Description copied from interface: FTPClient
Unregisters the given listener from the list of listeners.

Specified by:
removeFTPConnectionListener in interface FTPClient
Parameters:
l - Listener to unregister.

fireConnectionOpened

protected void fireConnectionOpened(FTPConnectionEvent evt)
Fires the ConnectionOpened event to all registered listeners.

Parameters:
evt - connection opened event.

fireConnectionClosed

protected void fireConnectionClosed(FTPConnectionEvent evt)
Fires the connection closed event to all registered listeners.

Parameters:
evt - connection closed event.