|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FTPClient
A contract for FTPClient
implementation classes.
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(String host)
Connects to the specified remote host host on the default
FTP port. |
void |
connect(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,
File destination,
int type,
boolean append)
Copies the contents of the source to the local file
destination . |
String |
executeCommand(String command)
Executes the given command returns the response back. |
int |
getBufferSize()
Returns the current buffer size being used by this FTPClient
. |
String |
getExplicitSSLProtocol()
Returns the SSL protocol that is in use for negotiating Explicit SSL connections. |
String |
getHelp()
Executes the HELP command on the remote host and returns the
response back. |
EventListenerList |
getListenerList()
Returns the list of registered listeners. |
ListParser |
getListParser()
Returns the current ListParser in use by this
FTPClient . |
InetAddress |
getLocalAddress()
Returns the InetAddress of the local host. |
String |
getLocalHost()
Returns the host name or IP address of the local host. |
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. |
Proxy |
getProxy()
Returns the current proxy configuration, if any. |
InetAddress |
getRemoteAddress()
Returns the Address of the remote host. |
String |
getRemoteHost()
Returns the fully qaulified domain name of the remote host. |
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. |
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. |
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 |
isPassiveIPSubstitutionEnabled()
Tells whether or not the substitution of passive IP address is enabled. |
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(String user,
String password)
Logs in to the remote host with the specified user id and password. |
void |
login(String user,
String password,
String account)
Logs in to the remote host with the specified user ID, pasword and account. |
void |
mountStructure(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 |
setExplicitSSLProtocol(String protocol)
Sets the SSL protocol to use when negotiating an Explicit SSL connection. |
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 |
setPassiveIPSubstitutionEnabled(boolean enable)
Sets or unsets the flag that determines whether or not to ignore the response (the IP address portion) of PASV command and substitute it with the original server IP address when making a PASSIVE data connection. |
void |
setProxy(Proxy proxy)
Sets the proxy server to use when making the control/data connections. |
void |
setSiteParameter(String param)
Sends a SITE command with the specified parameter(s). |
void |
setSSLContext(SSLContext context)
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(File source,
RemoteFile destination,
int type,
boolean append,
long skip)
copies the contents of local file source to the specified
remote file destination . |
Method Detail |
---|
void setTimeout(int timeout)
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.
timeout
- Timeout in milli seconds.int getTimeout()
FTPClient
.void setBufferSize(int bufferSize)
bufferSize
- Buffer size to use for transferring data over the data
connection.int getBufferSize()
FTPClient
.
void setListParser(ListParser listParser)
ListParser
to the specified listParser
.ListParser
objects are used to parsre the contents of a
remote directory in to RemoteFile
objects.
listParser
- The ListParser
to use to parse the contents of a
remote directory.ListParser getListParser()
ListParser
in use by this
FTPClient
.
ListParser
in use.void setSSLUsage(int sslUsage)
sslUsage
- SSL usage parameter to set.int getSSLUsage()
void setExplicitSSLProtocol(String protocol)
protocol
string will be sent (to the FTP
server) as a parameter to the AUTH
command. Valid values are
"SSL" and "TLS", however, this method does not restrict clients from
using other values.
protocol
- the security protocol to use when negotiating an Explicit SSL
connection.String getExplicitSSLProtocol()
setExplicitSSLProtocol(string protocol)
method is
not called, this method returns the default value "SSL".void setSSLContext(SSLContext context)
context
- SSLContextSSLContext getSSLContext()
void setDataChannelUnencrypted(boolean dataChannelUnencrypted)
dataChannelUnencrypted
- whether or not to encrypt the data channel.boolean isDataChannelUnencrypted()
true
, if the data channel encryption os ON,
false
, otherwise.boolean isSecured()
true
, if this connection is secured.
false
, othherwise.void connect(String host) throws FTPException, ConnectionException
host
on the default
FTP port.
host
- Host name or IP address of the remote host.
FTPException
ConnectionException
void connect(String host, int port) throws FTPException, ConnectionException
host
, on the specified
port number port
.
host
- Host name or IP address of the remote host.port
- Port number to connect to.
FTPException
ConnectionException
void connect(FTPHost ftpHost) throws FTPException, ConnectionException
ftpHost
- Remote FTP host to connect to.
FTPException
ConnectionException
boolean isConnected()
FTPClient
is still connected to
to the remote host.
true
, if this FTPClient
is still
connected to the remote host. Otherwise, false
.void login(String user, String password) throws FTPException, ConnectionException
user
- User ID.password
- Password.
FTPException
ConnectionException
void login(String user, String password, String account) throws FTPException, ConnectionException
user
- User ID.password
- Password.account
- Account Name.
FTPException
ConnectionException
boolean isLoggedIn()
true
, if this client is logged in to the remote
host. false
otherwise.RemoteFile setWorkingDirectory(RemoteFile dir) throws FTPException, ConnectionException
dir
. Clients must send a PWD
command after
sending the CWD
command to make sure that the working
directory has changed.
dir
- New remote working directory to set.
FTPException
ConnectionException
RemoteFile setToParentDirectory() throws FTPException, ConnectionException
FTPException
ConnectionException
RemoteFile getWorkingDirectory() throws FTPException, ConnectionException
FTPException
ConnectionException
void setType(int type) throws FTPException, ConnectionException
type
.
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
FTPException
ConnectionException
int getType()
void setStructure(int structure) throws FTPException, ConnectionException
structure
.
structure
- New structure to set. Possible structure type are -
FTPConstants.STRUCTURE_FILE
FTPConstants.STRUCTURE_RECORD
FTPConstants.STRUCTURE_PAGE
FTPException
ConnectionException
int getStructure()
void setMode(int mode) throws FTPException, ConnectionException
mode
.
mode
- The new mode to set. Possible modes are -
FTPConstants.MODE_STREAM
FTPConstants.MODE_BLOCK
FTPConstants.MODE_COMPRESSED
FTPException
ConnectionException
int getMode()
void setPassive(boolean passive)
true
, marks that the data is to be transgerrred over a
passive data connection.
passive
- Value true
marks that the data is to be
transferred over a passive data connection. Otherwise, over an
active data connection.boolean isPassive()
true
if in passive mode. Otherwise,
false
.void createDirectory(RemoteFile dir) throws FTPException, ConnectionException
dir
on the remote
host.
dir
- New directory to create.
FTPException
ConnectionException
void createFile(RemoteFile file) throws FTPException, ConnectionException
file
- Path and name of the file.
FTPException
ConnectionException
void deleteDirectory(RemoteFile dir) throws FTPException, ConnectionException
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.
dir
- Directory to delete.
FTPException
ConnectionException
void deleteFile(RemoteFile file) throws FTPException, ConnectionException
file
from the remote system.
file
- File to be deleted.
FTPException
ConnectionException
void delete(RemoteFile path) throws FTPException, ConnectionException
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.
path
- The file to delete.
FTPException
ConnectionException
void rename(RemoteFile from, RemoteFile to) throws FTPException, ConnectionException
from
to to
.
from
- The file to be renamed.to
- New file name.
FTPException
ConnectionException
void noop() throws FTPException, ConnectionException
FTPException
ConnectionException
void abort() throws FTPException, ConnectionException
abort
command to the remote host.
FTPException
ConnectionException
void reinitialize() throws FTPException, ConnectionException
FTPException
ConnectionException
void disconnect() throws FTPException, ConnectionException
FTPClient
.
FTPException
ConnectionException
void close()
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.
void allocate(long bytes) throws FTPException, ConnectionException
bytes
- Number of bytes to allocate for this FTPClient
.
FTPException
ConnectionException
void restart(long bytes) throws FTPException, ConnectionException
bytes
- number of bytes to skip in the Input/Output stream.
FTPException
ConnectionException
String getSystemInfo() throws FTPException, ConnectionException
SYST
command.
FTPException
ConnectionException
String getHelp() throws FTPException, ConnectionException
HELP
command on the remote host and returns the
response back.
FTPException
ConnectionException
void setSiteParameter(String param) throws FTPException, ConnectionException
SITE
command with the specified parameter(s).
param
- Parameters or the SITE command.
FTPException
ConnectionException
void mountStructure(String path) throws FTPException, ConnectionException
path
- New path structure to mount.
FTPException
ConnectionException
String executeCommand(String command) throws FTPException, ConnectionException
command
- Command to execute.
FTPException
ConnectionException
InetAddress getRemoteAddress()
String getRemoteHost()
String getRemoteIPAddress()
int getRemotePort()
InetAddress getLocalAddress()
String getLocalHost()
String getLocalIPAddress()
int getLocalPort()
RemoteFile[] list() throws FTPException, ParseException, ConnectionException
FTPException
ParseException
ConnectionException
RemoteFile[] list(Filter filter) throws FTPException, ParseException, ConnectionException
filter
- the filter to use.
FTPException
ParseException
ConnectionException
RemoteFile[] list(RemoteFile dir) throws FTPException, ParseException, ConnectionException
dir
- directory whose children are to be retrieved
dir
.
FTPException
ParseException
ConnectionException
RemoteFile[] list(RemoteFile dir, Filter filter) throws FTPException, ParseException, ConnectionException
dir
- directory whose children are to be retrieved.filter
- Fiter to apply.
FTPException
ParseException
ConnectionException
void download(RemoteFile source, File destination, int type, boolean append) throws FTPException, ConnectionException
source
to the local file
destination
.
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.
FTPException
ConnectionException
void upload(File source, RemoteFile destination, int type, boolean append, long skip) throws FTPException, ConnectionException
source
to the specified
remote file destination
.
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.
FTPException
ConnectionException
void addControlConnectionListener(ControlConnectionListener l)
ControlConnection
associated with this FTPClient
.
l
- Listener to register.void removeControlConnectionListener(ControlConnectionListener l)
l
- Listner to remove from the registered listener list.void addDataConnectionListener(DataConnectionListener l)
FTPClient
.
l
- Listener to register.void removeDataConnectionListener(DataConnectionListener l)
l
- Listener to unregister.EventListenerList getListenerList()
void addFTPConnectionListener(FTPConnectionListener l)
l
- Listener to register.void removeFTPConnectionListener(FTPConnectionListener l)
l
- Listener to unregister.void setPassiveIPSubstitutionEnabled(boolean enable)
enable
- true
to enable the IP address substitution;
false
to disable it.boolean isPassiveIPSubstitutionEnabled()
true
, if the addressed retunred by the server in
response to a PASV command will be ignored and substituted with
the original server's IP address; false
, otherewise.void setProxy(Proxy proxy)
proxy
- the proxy server to use when making the control/data
connections. Supported proxy types are - SOCKS and DIRECT.Proxy getProxy()
null
, if there is no proxy set.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |