com.enterprisedt.net.ftp
Class FTPClient

java.lang.Object
  extended by com.enterprisedt.net.ftp.FTPClient
All Implemented Interfaces:
FTPClientInterface

public class FTPClient
extends java.lang.Object
implements FTPClientInterface

Supports client-side FTP. Most common FTP operations are present in this class.

Version:
$Revision: 1.95 $
Author:
Bruce Blackshaw

Field Summary
static byte CARRIAGE_RETURN
          Used for ASCII translation
protected  FTPControlSocket control
          Socket responsible for controlling the connection
protected  java.lang.String controlEncoding
          Encoding used on control socket
protected  int controlPort
          Control port number.
static java.lang.String cvsId
          Revision control id
protected  FTPDataSocket data
          Socket responsible for transferring the data
static int DEFAULT_BUFFER_SIZE
          Default transfer buffer size
static java.lang.String DEFAULT_ENCODING
          Default encoding used for control data
static java.util.Locale[] DEFAULT_LISTING_LOCALES
          Default locales
static int DEFAULT_MONITOR_INTERVAL
          Default byte interval for transfer monitor
static int DEFAULT_TIMEOUT
          Default timeout
protected  boolean detectTransferMode
          If true, filetypes are autodetected and transfer mode changed to binary/ASCII as required
protected  DirectoryEmptyStrings dirEmptyStrings
          Matcher for directory empty
protected  FileNotFoundStrings fileNotFoundStrings
          Matcher for permission denied
static byte[] FTP_LINE_SEPARATOR
          Used for ASCII translation
protected  java.lang.String id
          Id of instance
protected  FTPReply lastReply
          Holds the last reply from the server on the control socket
protected  FTPReply lastValidReply
          Holds the last valid reply from the server on the control socket
static byte LINE_FEED
          Used for ASCII translation
protected  FTPMessageListener messageListener
          Message listener
protected  FTPProgressMonitor monitor
          Progress monitor
protected  FTPProgressMonitorEx monitorEx
          File transfer listener
protected  long monitorInterval
          Bytes transferred in between monitor callbacks
protected  java.net.InetAddress remoteAddr
          Address of the remote server.
protected  java.lang.String remoteHost
          Name/IP of remote host
protected  int serverWakeupInterval
          Interval in seconds in between server wakeups.
protected  int timeout
          Socket timeout for both data and control.
protected  int transferBufferSize
          Size of transfer buffers
protected  TransferCompleteStrings transferCompleteStrings
          Matcher for transfer complete
protected  FTPTransferType transferType
          Record of the transfer type - make the default ASCII
 
Constructor Summary
FTPClient()
          Default constructor should now always be used together with setter methods in preference to other constructors (now deprecated).
FTPClient(java.net.InetAddress remoteAddr)
          Deprecated. use setter methods to set properties
FTPClient(java.net.InetAddress remoteAddr, int controlPort)
          Deprecated. use setter methods to set properties
FTPClient(java.net.InetAddress remoteAddr, int controlPort, int timeout)
          Deprecated. use setter methods to set properties
FTPClient(java.net.InetAddress remoteAddr, int controlPort, int timeout, java.lang.String encoding)
          Deprecated. use setter methods to set properties
FTPClient(java.lang.String remoteHost)
          Deprecated. use setter methods to set properties
FTPClient(java.lang.String remoteHost, int controlPort)
          Deprecated. use setter methods to set properties
FTPClient(java.lang.String remoteHost, int controlPort, int timeout)
          Deprecated. use setter methods to set properties
FTPClient(java.lang.String remoteHost, int controlPort, int timeout, java.lang.String encoding)
          Deprecated. use setter methods to set properties
 
Method Summary
protected  void abort()
          Abort the current action
 void account(java.lang.String accountInfo)
          Supply account information string to the server.
 void cancelResume()
          Cancel the resume.
 void cancelTransfer()
          Cancels the current transfer.
 void cdup()
          Change the remote working directory to the parent directory
 void chdir(java.lang.String dir)
          Change the remote working directory to that supplied
protected  void checkConnection(boolean shouldBeConnected)
          Checks if the client has connected to the server and throws an exception if it hasn't.
protected  void chooseTransferMode(java.lang.String filename)
          Switch the transfer mode if requested and if necessary
static void clearSOCKS()
          Clear SOCKS settings.
protected  void closeDataSocket(java.io.InputStream stream)
          Close stream for data socket.
protected  void closeDataSocket(java.io.OutputStream stream)
          Close stream for data socket
 void connect()
          Connects to the server at the address and port number defined in the constructor.
 boolean connected()
          Is this client connected?
 void debugResponses(boolean on)
          Deprecated. use the Logger class to switch debugging on and off
 void delete(java.lang.String remoteFile)
          Delete the specified remote file
 java.lang.String[] dir()
          List current directory's contents as an array of strings of filenames.
 java.lang.String[] dir(java.lang.String dirname)
          List a directory's contents as an array of strings of filenames.
 java.lang.String[] dir(java.lang.String dirname, boolean full)
          List a directory's contents as an array of strings.
 FTPFile[] dirDetails(java.lang.String dirname)
          List a directory's contents as an array of FTPFile objects.
 java.lang.String executeCommand(java.lang.String command)
          Request that the remote server execute the literal command supplied.
 boolean exists(java.lang.String remoteFile)
          Does the named file exist in the current server directory?
 java.lang.String[] features()
          Get the server supplied features
 FTPFile fileDetails(java.lang.String name)
          Uses the MLST command to find out details about the named file.
protected  void forceResumeOff()
          Force the resume flag off.
 void get(java.io.OutputStream destStream, java.lang.String remoteFile)
          Get data from the FTP server.
 byte[] get(java.lang.String remoteFile)
          Get data from the FTP server.
 void get(java.lang.String localPath, java.lang.String remoteFile)
          Get data from the FTP server.
 int getActiveHighPort()
          Get the upper limit of the port range for active mode.
 java.lang.String getActiveIPAddress()
          Get the active IP address that is set.
 int getActiveLowPort()
          Get the lower limit of the port range for active mode.
static java.lang.String getBuildTimestamp()
          Get the build timestamp
 FTPConnectMode getConnectMode()
           
 java.lang.String getControlEncoding()
          Get the encoding used for the control connection
 int getControlPort()
          Deprecated. Use FTPClientInterface.getRemotePort() instead.
 int getDeleteCount()
          Get the number of files deleted since the count was reset
 boolean getDetectTransferMode()
          Get the detect transfer mode
 DirectoryEmptyStrings getDirectoryEmptyMessages()
          Get class that holds fragments of server messages that indicate a directory is empty.
 int getDownloadCount()
          Get the number of files downloaded since the count was reset
 FileNotFoundStrings getFileNotFoundMessages()
          Get class that holds fragments of server messages that indicate a file was not found.
 java.lang.String getId()
          Get the identifying string for this instance
 FTPReply getLastReply()
          Gets the last reply from the server, whether valid or not
 FTPReply getLastValidReply()
          Gets the latest valid reply from the server
 boolean getListenOnAllInterfaces()
          Are we listening on all interfaces in active mode, which is the default?
 FTPMessageListener getMessageListener()
           
 long getMonitorInterval()
          Get the bytes transferred between each callback on the progress monitor
 FTPProgressMonitor getProgressMonitor()
          Get the reference to the progress monitor
 FTPProgressMonitorEx getProgressMonitorEx()
          Get reference to the transfer listener
 java.net.InetAddress getRemoteAddr()
           
 java.lang.String getRemoteHost()
          Returns the IP address or name of the remote host.
 int getRemotePort()
          Returns the control-port being connected to on the remote server.
 int getServerWakeupInterval()
          Get server wakeup interval in seconds.
 int getTimeout()
          Get the TCP timeout
 int getTransferBufferSize()
          Get the size of the buffers used in writing to and reading from the data sockets
 TransferCompleteStrings getTransferCompleteMessages()
          Get class that holds fragments of server messages that indicate a transfer completed.
 FTPTransferType getType()
          Get the current transfer type
 int getUploadCount()
          Get the number of files uploaded since the count was reset
static int[] getVersion()
          Get the version of edtFTPj
 java.lang.String help(java.lang.String command)
          Get the help text for the specified command
protected  void initGet(java.lang.String remoteFile)
          Request to the server that the get is set up
protected  void initialize(FTPControlSocket control)
          Set the control socket explicitly
protected  java.lang.String initPut(java.lang.String remoteFile, boolean append)
          Request the server to set up the put
static void initSOCKS(java.lang.String port, java.lang.String host)
          Set up SOCKS v4/v5 proxy settings.
static void initSOCKSAuthentication(java.lang.String username, java.lang.String password)
          Set up SOCKS username and password for SOCKS username/password authentication.
 boolean isAutoPassiveIPSubstitution()
          Is automatic substitution of the remote host IP set to be on for passive mode connections?
 boolean isDeleteOnFailure()
          If true, delete partially written files when exceptions are thrown during a download
 boolean isStrictReturnCodes()
          Determine if strict checking of return codes is switched on.
 boolean isTransferCancelled()
          Has the current transfer been cancelled?
 void keepAlive()
          Tries to keep the current connection alive by sending an innocuous commmand to signal that the client is still active
 java.lang.String list(java.lang.String dirname)
          Deprecated. As of FTP 1.1, replaced by dir(String)
 java.lang.String list(java.lang.String dirname, boolean full)
          Deprecated. As of FTP 1.1, replaced by dir(String,boolean)
 void login(java.lang.String user, java.lang.String password)
          Login into an account on the FTP server.
 void login(java.lang.String user, java.lang.String password, java.lang.String accountInfo)
          Login into an account on the FTP server.
 void mkdir(java.lang.String dir)
          Create the specified remote working directory
 java.util.Date modtime(java.lang.String remoteFile)
          Get modification time for a remote file.
 void noOperation()
          Send a "no operation" message that does nothing.
 void password(java.lang.String password)
          Supplies the password for a previously supplied username to log into the FTP server.
 java.lang.String put(byte[] bytes, java.lang.String remoteFile)
          Put data onto the FTP server.
 java.lang.String put(byte[] bytes, java.lang.String remoteFile, boolean append)
          Put data onto the FTP server.
 java.lang.String put(java.io.InputStream srcStream, java.lang.String remoteFile)
          Put a stream of data onto the FTP server.
 java.lang.String put(java.io.InputStream srcStream, java.lang.String remoteFile, boolean append)
          Put a stream of data onto the FTP server.
 java.lang.String put(java.lang.String localPath, java.lang.String remoteFile)
          Put a local file onto the FTP server.
 java.lang.String put(java.lang.String localPath, java.lang.String remoteFile, boolean append)
          Put a local file onto the FTP server.
 java.lang.String pwd()
          Get the current remote working directory
 void quit()
          Quit the FTP session
 void quitImmediately()
          Quit the FTP session immediately.
 java.lang.String quote(java.lang.String command)
          Issue arbitrary ftp commands to the FTP server.
 java.lang.String quote(java.lang.String command, java.lang.String[] validCodes)
          Issue arbitrary ftp commands to the FTP server.
protected  int readChar(java.io.LineNumberReader in)
          Attempts to read a single character from the given InputStream.
 int readChunk(java.io.BufferedInputStream in, byte[] chunk, int chunksize)
          Attempts to read a specified number of bytes from the given InputStream and place it in the given byte-array.
protected  java.lang.String readLine(java.io.LineNumberReader in)
          Attempts to read a single line from the given InputStream.
 void rename(java.lang.String from, java.lang.String to)
          Rename a file or directory
 void resetDeleteCount()
          Reset the count of deleted files to zero.
 void resetDownloadCount()
          Reset the count of downloaded files to zero.
 void resetTransferMode(FTPTransferType previousType)
          Reset the transfer mode back to what it should be, if it has changed.
 void resetUploadCount()
          Reset the count of uploaded files to zero.
 void restart(long size)
          Issue the RESTart command to the remote server.
 void resume()
          Make the next file transfer (put or get) resume.
 void rmdir(java.lang.String dir)
          Delete the specified remote working directory
 FTPReply sendCommand(java.lang.String command)
          Send a command to the server and get the reply
 void sendServerWakeup()
          Wake up the server during a transfer to prevent a timeout from occuring.
 void setActiveIPAddress(java.lang.String activeIP)
          We can force PORT to send a fixed IP address, which can be useful with certain NAT configurations.
 void setActivePortRange(int lowest, int highest)
          Force a certain range of ports to be used in active mode.
 void setAutoPassiveIPSubstitution(boolean autoPassiveIPSubstitution)
          Set automatic substitution of the remote host IP on if in passive mode
 void setConnectMode(FTPConnectMode mode)
          Set the connect mode
 void setControlEncoding(java.lang.String controlEncoding)
          Set the control socket's encoding.
 void setControlPort(int controlPort)
          Deprecated. Use FTPClientInterface.setRemotePort(int) instead.
 void setDeleteOnFailure(boolean deleteOnFailure)
          Switch on or off the automatic deletion of partially written files that are left when an exception is thrown during a download
 void setDetectTransferMode(boolean detectTransferMode)
          Set autodetect of filetypes on or off.
 void setDirectoryEmptyMessages(DirectoryEmptyStrings dirEmptyStrings)
          Set a new instance of the strings class
 void setFileNotFoundMessages(FileNotFoundStrings fileNotFoundStrings)
          Set a new instance of the strings class
 void setForceUniqueNames(boolean forceUnique)
          Set to true if the STOU command is always to be used when uploading files, even if a filename is supplied.
 void setFTPFileFactory(FTPFileFactory fileFactory)
          Override the chosen file factory with a user created one - meaning that a specific parser has been selected
 void setId(java.lang.String id)
          Set the identifying string for this instance
 void setListenOnAllInterfaces(boolean listenOnAll)
          Listen on all interfaces for active mode transfers (the default).
 void setMessageListener(FTPMessageListener listener)
          Set a listener that handles all FTP messages
 void setMonitorInterval(long interval)
          Set the number of bytes transferred between each callback on the progress monitor param interval bytes to be transferred before a callback
 void setParserLocale(java.util.Locale locale)
          Deprecated. @see FTPClient#setParserLocales(Locale[])
 void setParserLocales(java.util.Locale[] locales)
          Set the list of locales to be tried for date parsing of dir listings
 void setPORTIP(java.lang.String IPAddress)
          Deprecated.  
 void setProgressMonitor(FTPProgressMonitor monitor)
          Set a progress monitor for callbacks.
 void setProgressMonitor(FTPProgressMonitor monitor, long interval)
          Set a progress monitor for callbacks.
 void setProgressMonitorEx(FTPProgressMonitorEx monitorEx)
          Set reference to the transfer listener
 void setRemoteAddr(java.net.InetAddress remoteAddr)
          Set the remote address
 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 control to connect to on the remote server.
 void setServerWakeupInterval(int interval)
          Set server wakeup interval in seconds.
 void setStrictReturnCodes(boolean strict)
          Set strict checking of FTP return codes.
 void setTimeout(int millis)
          Set the SO_TIMEOUT in milliseconds on the underlying socket.
 void setTransferBufferSize(int size)
          Set the size of the buffers used in writing to and reading from the data sockets
 void setTransferCompleteMessages(TransferCompleteStrings transferCompleteStrings)
          Set a new instance of the strings class
 void setType(FTPTransferType type)
          Set the transfer type
protected  void setupDataSocket()
          Set up the data socket
 boolean site(java.lang.String command)
          Run a site-specific command on the server.
 long size(java.lang.String remoteFile)
          Get the size of a remote file.
 java.lang.String stat()
          Sends stat message to enquire about the status of a transfer.
 java.lang.String system()
          Get the type of the OS at the server
 java.lang.String toString()
          String representation
 void user(java.lang.String user)
          Supply the user name to log into an account on the FTP server.
 void validateReply(FTPReply reply, java.lang.String expectedReplyCode)
          Validate an FTPReply
 void validateReply(FTPReply reply, java.lang.String[] expectedReplyCodes)
          Validate an FTPReply
 void validateTransfer()
          Validate that the put() or get() was successful.
protected  void validateTransferOnError(java.io.IOException ex)
          Validate a transfer when an error has occurred on the data channel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

cvsId

public static java.lang.String cvsId
Revision control id


DEFAULT_MONITOR_INTERVAL

public static final int DEFAULT_MONITOR_INTERVAL
Default byte interval for transfer monitor

See Also:
Constant Field Values

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
Default transfer buffer size

See Also:
Constant Field Values

DEFAULT_TIMEOUT

public static final int DEFAULT_TIMEOUT
Default timeout

See Also:
Constant Field Values

DEFAULT_ENCODING

public static final java.lang.String DEFAULT_ENCODING
Default encoding used for control data

See Also:
Constant Field Values

CARRIAGE_RETURN

public static final byte CARRIAGE_RETURN
Used for ASCII translation

See Also:
Constant Field Values

LINE_FEED

public static final byte LINE_FEED
Used for ASCII translation

See Also:
Constant Field Values

FTP_LINE_SEPARATOR

public static final byte[] FTP_LINE_SEPARATOR
Used for ASCII translation


DEFAULT_LISTING_LOCALES

public static java.util.Locale[] DEFAULT_LISTING_LOCALES
Default locales


control

protected FTPControlSocket control
Socket responsible for controlling the connection


data

protected FTPDataSocket data
Socket responsible for transferring the data


timeout

protected int timeout
Socket timeout for both data and control. In milliseconds


serverWakeupInterval

protected int serverWakeupInterval
Interval in seconds in between server wakeups. O is not enabled


remoteAddr

protected java.net.InetAddress remoteAddr
Address of the remote server.


remoteHost

protected java.lang.String remoteHost
Name/IP of remote host


id

protected java.lang.String id
Id of instance


controlPort

protected int controlPort
Control port number.


controlEncoding

protected java.lang.String controlEncoding
Encoding used on control socket


dirEmptyStrings

protected DirectoryEmptyStrings dirEmptyStrings
Matcher for directory empty


transferCompleteStrings

protected TransferCompleteStrings transferCompleteStrings
Matcher for transfer complete


fileNotFoundStrings

protected FileNotFoundStrings fileNotFoundStrings
Matcher for permission denied


detectTransferMode

protected boolean detectTransferMode
If true, filetypes are autodetected and transfer mode changed to binary/ASCII as required


monitorInterval

protected long monitorInterval
Bytes transferred in between monitor callbacks


transferBufferSize

protected int transferBufferSize
Size of transfer buffers


monitor

protected FTPProgressMonitor monitor
Progress monitor


messageListener

protected FTPMessageListener messageListener
Message listener


monitorEx

protected FTPProgressMonitorEx monitorEx
File transfer listener


transferType

protected FTPTransferType transferType
Record of the transfer type - make the default ASCII


lastValidReply

protected FTPReply lastValidReply
Holds the last valid reply from the server on the control socket


lastReply

protected FTPReply lastReply
Holds the last reply from the server on the control socket

Constructor Detail

FTPClient

public FTPClient(java.lang.String remoteHost)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket

Parameters:
remoteHost - the remote hostname
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.lang.String remoteHost,
                 int controlPort)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket

Parameters:
remoteHost - the remote hostname
controlPort - port for control stream (-1 for default port)
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.lang.String remoteHost,
                 int controlPort,
                 int timeout)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket

Parameters:
remoteHost - the remote hostname
controlPort - port for control stream (use -1 for the default port)
timeout - the length of the timeout, in milliseconds (pass in 0 for no timeout)
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.lang.String remoteHost,
                 int controlPort,
                 int timeout,
                 java.lang.String encoding)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket

Parameters:
remoteHost - the remote hostname
controlPort - port for control stream (use -1 for the default port)
timeout - the length of the timeout, in milliseconds (pass in 0 for no timeout)
encoding - character encoding used for data
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.net.InetAddress remoteAddr)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket

Parameters:
remoteAddr - the address of the remote host
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.net.InetAddress remoteAddr,
                 int controlPort)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket. Allows setting of control port (normally set by default to 21).

Parameters:
remoteAddr - the address of the remote host
controlPort - port for control stream
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.net.InetAddress remoteAddr,
                 int controlPort,
                 int timeout)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket. Allows setting of control port (normally set by default to 21).

Parameters:
remoteAddr - the address of the remote host
controlPort - port for control stream (-1 for default port)
timeout - the length of the timeout, in milliseconds (pass in 0 for no timeout)
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient(java.net.InetAddress remoteAddr,
                 int controlPort,
                 int timeout,
                 java.lang.String encoding)
          throws java.io.IOException,
                 FTPException
Deprecated. use setter methods to set properties

Constructor. Creates the control socket. Allows setting of control port (normally set by default to 21).

Parameters:
remoteAddr - the address of the remote host
controlPort - port for control stream (-1 for default port)
timeout - the length of the timeout, in milliseconds (pass in 0 for no timeout)
encoding - character encoding used for data
Throws:
java.io.IOException
FTPException

FTPClient

public FTPClient()
Default constructor should now always be used together with setter methods in preference to other constructors (now deprecated). The connect() method is used to perform the actual connection to the remote host - but only for this constructor. Deprecated constructors connect in the constructor and connect() is not required (and cannot be called).

Method Detail

getVersion

public static int[] getVersion()
Get the version of edtFTPj

Returns:
int array of {major,middle,minor} version numbers

getBuildTimestamp

public static java.lang.String getBuildTimestamp()
Get the build timestamp

Returns:
d-MMM-yyyy HH:mm:ss z build timestamp

connect

public void connect()
             throws java.io.IOException,
                    FTPException
Connects to the server at the address and port number defined in the constructor. Must be performed before login() or user() is called.

Specified by:
connect in interface FTPClientInterface
Throws:
java.io.IOException - Thrown if there is a TCP/IP-related error.
FTPException - Thrown if there is an error related to the FTP protocol.

connected

public boolean connected()
Is this client connected?

Specified by:
connected in interface FTPClientInterface
Returns:
true if connected, false otherwise

checkConnection

protected void checkConnection(boolean shouldBeConnected)
                        throws FTPException
Checks if the client has connected to the server and throws an exception if it hasn't. This is only intended to be used by subclasses

Throws:
FTPException - Thrown if the client has not connected to the server.

initialize

protected void initialize(FTPControlSocket control)
                   throws java.io.IOException
Set the control socket explicitly

Parameters:
control - control socket reference
Throws:
java.io.IOException

debugResponses

public void debugResponses(boolean on)
Deprecated. use the Logger class to switch debugging on and off

Switch debug of responses on or off

Parameters:
on - true if you wish to have responses to the log stream, false otherwise

getId

public java.lang.String getId()
Get the identifying string for this instance

Specified by:
getId in interface FTPClientInterface
Returns:
identifying string

setId

public void setId(java.lang.String id)
Set the identifying string for this instance

Specified by:
setId in interface FTPClientInterface
Parameters:
id - identifying string

getDownloadCount

public int getDownloadCount()
Get the number of files downloaded since the count was reset

Specified by:
getDownloadCount in interface FTPClientInterface
Returns:
download file count

resetDownloadCount

public void resetDownloadCount()
Reset the count of downloaded files to zero.

Specified by:
resetDownloadCount in interface FTPClientInterface

getUploadCount

public int getUploadCount()
Get the number of files uploaded since the count was reset

Specified by:
getUploadCount in interface FTPClientInterface
Returns:
upload file count

resetUploadCount

public void resetUploadCount()
Reset the count of uploaded files to zero.

Specified by:
resetUploadCount in interface FTPClientInterface

getDeleteCount

public int getDeleteCount()
Get the number of files deleted since the count was reset

Specified by:
getDeleteCount in interface FTPClientInterface
Returns:
deleted file count

resetDeleteCount

public void resetDeleteCount()
Reset the count of deleted files to zero.

Specified by:
resetDeleteCount in interface FTPClientInterface

setStrictReturnCodes

public void setStrictReturnCodes(boolean strict)
Set strict checking of FTP return codes. If strict checking is on (the default) code must exactly match the expected code. If strict checking is off, only the first digit must match.

Parameters:
strict - true for strict checking, false for loose checking

isStrictReturnCodes

public boolean isStrictReturnCodes()
Determine if strict checking of return codes is switched on. If it is (the default), all return codes must exactly match the expected code. If strict checking is off, only the first digit must match.

Returns:
true if strict return code checking, false if non-strict.

setListenOnAllInterfaces

public void setListenOnAllInterfaces(boolean listenOnAll)
Listen on all interfaces for active mode transfers (the default).

Parameters:
listenOnAll - true if listen on all interfaces, false to listen on the control interface

getListenOnAllInterfaces

public boolean getListenOnAllInterfaces()
Are we listening on all interfaces in active mode, which is the default?

Returns:
true if listening on all interfaces, false if listening just on the control interface

getFileNotFoundMessages

public FileNotFoundStrings getFileNotFoundMessages()
Get class that holds fragments of server messages that indicate a file was not found. New messages can be added.

The fragments are used when it is necessary to examine the message returned by a server to see if it is saying a file was not found. If an FTP server is returning a different message that still clearly indicates a file was not found, use this property to add a new server fragment to the repository via the add method. It would be helpful to email support at enterprisedt dot com to inform us of the message so it can be added to the next build.

Returns:
messages class

setFileNotFoundMessages

public void setFileNotFoundMessages(FileNotFoundStrings fileNotFoundStrings)
Set a new instance of the strings class

Parameters:
fileNotFoundStrings - new instance

getTransferCompleteMessages

public TransferCompleteStrings getTransferCompleteMessages()
Get class that holds fragments of server messages that indicate a transfer completed. New messages can be added.

The fragments are used when it is necessary to examine the message returned by a server to see if it is saying a transfer completed. If an FTP server is returning a different message that still clearly indicates a transfer failed, use this property to add a new server fragment to the repository via the add method. It would be helpful to email support at enterprisedt dot com to inform us of the message so it can be added to the next build.

Returns:
messages class

setTransferCompleteMessages

public void setTransferCompleteMessages(TransferCompleteStrings transferCompleteStrings)
Set a new instance of the strings class

Parameters:
transferCompleteStrings - new instance

getDirectoryEmptyMessages

public DirectoryEmptyStrings getDirectoryEmptyMessages()
Get class that holds fragments of server messages that indicate a directory is empty. New messages can be added.

The fragments are used when it is necessary to examine the message returned by a server to see if it is saying a directory is empty. If an FTP server is returning a different message that still clearly indicates a directory is empty, use this property to add a new server fragment to the repository via the add method. It would be helpful to email support at enterprisedt dot com to inform us of the message so it can be added to the next build.

Returns:
messages class

setDirectoryEmptyMessages

public void setDirectoryEmptyMessages(DirectoryEmptyStrings dirEmptyStrings)
Set a new instance of the strings class

Parameters:
dirEmptyStrings - new instance

setDetectTransferMode

public void setDetectTransferMode(boolean detectTransferMode)
Description copied from interface: FTPClientInterface
Set autodetect of filetypes on or off. If on, the transfer mode is switched from ASCII to binary and vice versa depending on the extension of the file. After the transfer, the mode is always returned to what it was before the transfer was performed. The default is off. If the filetype is unknown, the transfer mode is unchanged

Specified by:
setDetectTransferMode in interface FTPClientInterface
Parameters:
detectTransferMode - true if detecting transfer mode, false if not

getDetectTransferMode

public boolean getDetectTransferMode()
Description copied from interface: FTPClientInterface
Get the detect transfer mode

Specified by:
getDetectTransferMode in interface FTPClientInterface
Returns:
true if we are detecting binary and ASCII transfers from the file type

setForceUniqueNames

public void setForceUniqueNames(boolean forceUnique)
Set to true if the STOU command is always to be used when uploading files, even if a filename is supplied. Normally STOU is only used if the supplied remote filename is null or the empty string.

Parameters:
forceUnique - true if STOU is always to be used

chooseTransferMode

protected void chooseTransferMode(java.lang.String filename)
                           throws java.io.IOException,
                                  FTPException
Switch the transfer mode if requested and if necessary

Parameters:
filename - filename of file to be transferred
Throws:
FTPException
java.io.IOException

setTimeout

public void setTimeout(int millis)
                throws java.io.IOException
Set the SO_TIMEOUT in milliseconds on the underlying socket. If set this means the socket will block in a read operation only for this length of time - useful if the FTP sever has hung, for example. The default is 0, which is an infinite timeout. Note that for JREs 1.4+, the timeout is also used when first connecting to the remote host.

Specified by:
setTimeout in interface FTPClientInterface
Parameters:
millis - The length of the timeout, in milliseconds
Throws:
java.io.IOException

getTimeout

public int getTimeout()
Get the TCP timeout

Specified by:
getTimeout in interface FTPClientInterface
Returns:
timeout that is used, in milliseconds

getRemotePort

public int getRemotePort()
Returns the control-port being connected to on the remote server. Note that this method replaces getControlPort().

Specified by:
getRemotePort in interface FTPClientInterface
Returns:
Returns the port being connected to on the remote server.

setRemotePort

public void setRemotePort(int remotePort)
                   throws FTPException
Set the control to connect to on the remote server. Can only do this if not already connected. Note that this method replaces setControlPort(int).

Specified by:
setRemotePort in interface FTPClientInterface
Parameters:
remotePort - The port to use.
Throws:
FTPException - Thrown if the client is already connected to the server.

getControlPort

public int getControlPort()
Deprecated. Use FTPClientInterface.getRemotePort() instead.

Returns the control-port being connected to on the remote server.

Returns:
Returns the port being connected to on the remote server.

setControlPort

public void setControlPort(int controlPort)
                    throws FTPException
Deprecated. Use FTPClientInterface.setRemotePort(int) instead.

Set the control to connect to on the remote server. Can only do this if not already connected.

Parameters:
controlPort - The port to use.
Throws:
FTPException - Thrown if the client is already connected to the server.

getRemoteAddr

public java.net.InetAddress getR