com.enterprisedt.net.ftp.pro
Class ProFTPClient

java.lang.Object
  extended by com.enterprisedt.net.ftp.FTPClient
      extended by com.enterprisedt.net.ftp.pro.ProFTPClient
All Implemented Interfaces:
FTPClientInterface, ProFTPClientInterface
Direct Known Subclasses:
SSLFTPClient

public class ProFTPClient
extends FTPClient
implements ProFTPClientInterface

Subclass of FTPClient that adds numerous useful methods, mainly for getting and putting of multiple files, including recursively going through directories. Also supports IPV6.

Version:
$Revision: 1.18 $
Author:
Bruce Blackshaw

Field Summary
static java.lang.String cvsId
          Revision control id
protected  ProxySettings proxySettings
          The proxy settings
 
Fields inherited from class com.enterprisedt.net.ftp.FTPClient
CARRIAGE_RETURN, control, controlEncoding, controlPort, data, dataChannelCallback, dataReceiveBufferSize, dataSendBufferSize, DEFAULT_BUFFER_SIZE, DEFAULT_ENCODING, DEFAULT_LISTING_LOCALES, DEFAULT_MONITOR_INTERVAL, DEFAULT_RETRY_COUNT, DEFAULT_RETRY_DELAY, DEFAULT_TIMEOUT, detectTransferMode, dirEmptyStrings, fileNotFoundStrings, FTP_LINE_SEPARATOR, id, lastReply, lastValidReply, LINE_FEED, messageListener, monitor, monitorEx, monitorInterval, password, remoteAddr, remoteHost, serverWakeupInterval, throttler, timeout, transferBufferSize, transferCompleteStrings, transferType, user
 
Constructor Summary
ProFTPClient()
          Default constructor.
 
Method Summary
 void connect()
          Connects to the server at the address and port number defined in the constructor.
 void enableModeZCompression()
          Set MODE Z so that all subsequent transfers are compressed
 int getCountBeforeSleep()
          Get the number of transfers set before sleeping
protected  java.io.InputStream getInputStream()
          Get the data input stream.
 int getLocalCRC(byte[] bytes)
          Get the CRC-32 checksum for the supplied byte array
 int getLocalCRC(java.lang.String path)
          Get the CRC-32 checksum for the named local file.
 int getMaxTransferRate()
          Get the maximum bandwidth for transfers
protected  java.io.OutputStream getOutputStream()
          Get the data input stream.
 ProxySettings getProxySettings()
          Get the proxy settings instance.
 java.lang.String getRemoteCRC(java.lang.String path)
          Get the CRC-32 checksum for the named remote file.
 int getSleepTime()
          Get the number of seconds spent asleep
protected  void integrityCheckTransferCRC(byte[] localBytes, java.lang.String remoteFile)
           
protected  void integrityCheckTransferCRC(java.lang.String localPath, java.lang.String remoteFile)
           
protected  void integrityCheckTransferSize(long length, java.lang.String remoteFile)
           
 boolean isModeZCompressionEnabled()
          Are we in mode z currently?
 boolean isSleepEnabled()
          Is sleeping enabled?
 boolean isTransferIntegrityCheck()
          Is integrity checking of transfers enabled?
 void mdelete(java.io.FileFilter filter)
          Deletes all files matching the filter in the current remote directory only
 void mdelete(java.lang.String wildcard)
          Deletes all files matching the wildcard in the current remote directory only
 void mdelete(java.lang.String remoteDir, java.io.FileFilter filter, boolean recurse)
          Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter.
 void mdelete(java.lang.String remoteDir, java.lang.String wildcard, boolean recurse)
          Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied wildcard.
 void mget(java.lang.String localDir, java.io.FileFilter filter)
          Get all files matching the filter in the current remote directory only into the supplied local directory
 void mget(java.lang.String localDir, java.lang.String wildcard)
          Get all files matching the filter in the current remote directory only into the supplied local directory
 void mget(java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter, boolean recurse)
          Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.
 void mget(java.lang.String localDir, java.lang.String remoteDir, java.lang.String wildcard, boolean recurse)
          Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.
 void mput(java.lang.String localDir, java.io.FileFilter filter)
          Put all files matching the wildcard in the supplied local directory only into the current remote directory
 void mput(java.lang.String localDir, java.lang.String wildcard)
          Put all files matching the wildcard in the supplied local directory only into the current remote directory
 void mput(java.lang.String localDir, java.lang.String remoteDir, java.io.FileFilter filter, boolean recurse)
          Puts this entire directory and its contents.
 void mput(java.lang.String localDir, java.lang.String remoteDir, java.lang.String wildcard, boolean recurse)
          Puts this entire directory and its contents.
protected  void postTransferChecks(byte[] localBytes, java.lang.String remotePath, FTPTransferType type, boolean append)
          Can be overridden by subclasses to do any necessary post transfer checking.
protected  void postTransferChecks(java.lang.String localPath, java.lang.String remotePath, FTPTransferType type, boolean append)
          Can be overridden by subclasses to do any necessary post transfer checking.
 void rmdir(java.lang.String remoteDir, boolean recurse)
          Delete this remote directory.
 void setCountBeforeSleep(int countBeforeSleep)
          Set the number of transfers required before sleeping
 void setMaxTransferRate(int thresholdBytesPerSecond)
          Set the maximum transfer rates in bytes per sec
 void setSleepEnabled(boolean sleepEnabled)
          Set sleeping enabled to be on or off
 void setSleepTime(int sleepTime)
          Set the time spent asleep
 void setTransferIntegrityCheck(boolean enable)
          Enable or disable integrity checking of transfers.
 
Methods inherited from class com.enterprisedt.net.ftp.FTPClient
abort, account, cancelResume, cancelTransfer, cdup, chdir, checkConnection, chooseTransferMode, clearSOCKS, closeDataSocket, closeDataSocket, connected, debugResponses, delete, dir, dir, dir, dirDetails, dirDetails, executeCommand, exists, features, fileDetails, forceResumeOff, get, get, get, getActiveHighPort, getActiveIPAddress, getActiveLowPort, getBuildTimestamp, getConnectMode, getControlEncoding, getControlPort, getDataReceiveBufferSize, getDataSendBufferSize, getDeleteCount, getDetectTransferMode, getDirectoryEmptyMessages, getDownloadCount, getFileNotFoundMessages, getId, getLastReply, getLastValidReply, getListenOnAllInterfaces, getMessageListener, getMonitorInterval, getProgressMonitor, getProgressMonitorEx, getRemoteAddr, getRemoteHost, getRemotePort, getRetryCount, getRetryDelay, getServerWakeupInterval, getTimeout, getTransferBufferSize, getTransferCompleteMessages, getType, getUploadCount, getVersion, help, initGet, initialize, initPut, initSOCKS, initSOCKSAuthentication, isAutoPassiveIPSubstitution, isDeleteOnFailure, isStrictReturnCodes, isTransferCancelled, keepAlive, list, list, login, login, mkdir, modtime, noOperation, password, put, put, put, put, put, put, pwd, quit, quitImmediately, quote, quote, readChar, readChunk, readLine, reconnect, rename, resetDeleteCount, resetDownloadCount, resetTransferMode, resetUploadCount, restart, resume, rmdir, sendCommand, sendServerWakeup, setActiveIPAddress, setActivePortRange, setAutoPassiveIPSubstitution, setConnectMode, setControlEncoding, setControlPort, setDataChannelCallback, setDataReceiveBufferSize, setDataSendBufferSize, setDeleteOnFailure, setDetectTransferMode, setDirectoryEmptyMessages, setFileNotFoundMessages, setForceUniqueNames, setFTPFileFactory, setId, setListenOnAllInterfaces, setMessageListener, setModTime, setMonitorInterval, setParserLocale, setParserLocales, setPORTIP, setProgressMonitor, setProgressMonitor, setProgressMonitorEx, setRemoteAddr, setRemoteHost, setRemotePort, setRetryCount, setRetryDelay, setServerWakeupInterval, setStrictReturnCodes, setTimeout, setTransferBufferSize, setTransferCompleteMessages, setType, setupDataSocket, site, size, stat, system, toString, user, validateReply, validateReply, validateTransfer, validateTransferOnError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.enterprisedt.net.ftp.pro.ProFTPClientInterface
getProgressMonitorEx, setMonitorInterval, setProgressMonitorEx
 
Methods inherited from interface com.enterprisedt.net.ftp.FTPClientInterface
cancelResume, cancelTransfer, cdup, chdir, connected, delete, dir, dir, dir, dirDetails, dirDetails, executeCommand, exists, get, get, get, getDeleteCount, getDetectTransferMode, getDownloadCount, getId, getMonitorInterval, getRemoteHost, getRemotePort, getTimeout, getType, getUploadCount, keepAlive, mkdir, modtime, put, put, put, put, put, put, pwd, quit, quitImmediately, rename, resetDeleteCount, resetDownloadCount, resetUploadCount, resume, rmdir, setControlEncoding, setDetectTransferMode, setId, setModTime, setProgressMonitor, setProgressMonitor, setRemoteHost, setRemotePort, setTimeout, setType, size, system
 

Field Detail

cvsId

public static final java.lang.String cvsId
Revision control id

See Also:
Constant Field Values

proxySettings

protected ProxySettings proxySettings
The proxy settings

Constructor Detail

ProFTPClient

public ProFTPClient()
Default constructor. The FTPClient.connect() method is used to perform the actual connection to the remote host.

Method Detail

getProxySettings

public ProxySettings getProxySettings()
Get the proxy settings instance. Its properties can be set to use proxies.

Specified by:
getProxySettings in interface ProFTPClientInterface
Returns:
ProxySettings

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
Overrides:
connect in class FTPClient
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.

enableModeZCompression

public void enableModeZCompression()
                            throws java.io.IOException,
                                   FTPException
Set MODE Z so that all subsequent transfers are compressed

Throws:
java.io.IOException
FTPException

getLocalCRC

public int getLocalCRC(java.lang.String path)
                throws java.io.IOException
Get the CRC-32 checksum for the named local file.

Parameters:
path - local file path
Throws:
FTPException
java.io.IOException

getLocalCRC

public int getLocalCRC(byte[] bytes)
                throws java.io.IOException
Get the CRC-32 checksum for the supplied byte array

Parameters:
bytes - byte array
Throws:
FTPException
java.io.IOException

setTransferIntegrityCheck

public void setTransferIntegrityCheck(boolean enable)
Enable or disable integrity checking of transfers. This is only performed for binary transfers, and can't work when append is used.

Parameters:
enable - true to enable, false to disable

isTransferIntegrityCheck

public boolean isTransferIntegrityCheck()
Is integrity checking of transfers enabled?

Returns:
true if enabled, false if disabled

getRemoteCRC

public java.lang.String getRemoteCRC(java.lang.String path)
                              throws FTPException,
                                     java.io.IOException
Get the CRC-32 checksum for the named remote file. Not supported by all servers (requires the XCRC command).

Parameters:
path - file path on server
Throws:
FTPException
java.io.IOException

postTransferChecks

protected void postTransferChecks(java.lang.String localPath,
                                  java.lang.String remotePath,
                                  FTPTransferType type,
                                  boolean append)
                           throws FTPException,
                                  java.io.IOException
Can be overridden by subclasses to do any necessary post transfer checking.

Overrides:
postTransferChecks in class FTPClient
Parameters:
localPath - local file
remotePath - remote file
type - binary or ASCII
append -
Throws:
java.io.IOException
FTPException

integrityCheckTransferCRC

protected void integrityCheckTransferCRC(java.lang.String localPath,
                                         java.lang.String remoteFile)
                                  throws java.io.IOException,
                                         FTPException
Throws:
java.io.IOException
FTPException

integrityCheckTransferCRC

protected void integrityCheckTransferCRC(byte[] localBytes,
                                         java.lang.String remoteFile)
                                  throws java.io.IOException,
                                         FTPException
Throws:
java.io.IOException
FTPException

integrityCheckTransferSize

protected void integrityCheckTransferSize(long length,
                                          java.lang.String remoteFile)
                                   throws java.io.IOException,
                                          FTPException
Throws:
java.io.IOException
FTPException

postTransferChecks

protected void postTransferChecks(byte[] localBytes,
                                  java.lang.String remotePath,
                                  FTPTransferType type,
                                  boolean append)
                           throws FTPException,
                                  java.io.IOException
Can be overridden by subclasses to do any necessary post transfer checking.

Overrides:
postTransferChecks in class FTPClient
Parameters:
localBytes - local bytes to transfer
remotePath - remote file
transferType - binary or ASCII
append -
Throws:
FTPException
java.io.IOException

getInputStream

protected java.io.InputStream getInputStream()
                                      throws java.io.IOException
Get the data input stream. Not for general use!

Overrides:
getInputStream in class FTPClient
Returns:
Throws:
java.io.IOException

getOutputStream

protected java.io.OutputStream getOutputStream()
                                        throws java.io.IOException
Get the data input stream. Not for general use!

Overrides:
getOutputStream in class FTPClient
Returns:
Throws:
java.io.IOException

isModeZCompressionEnabled

public boolean isModeZCompressionEnabled()
Are we in mode z currently?

Returns:
true if in mode z, false otherwise

setMaxTransferRate

public void setMaxTransferRate(int thresholdBytesPerSecond)
Set the maximum transfer rates in bytes per sec

Specified by:
setMaxTransferRate in interface ProFTPClientInterface
Parameters:
thresholdBytesPerSecond - maximum bytes per second to transfer

getMaxTransferRate

public int getMaxTransferRate()
Get the maximum bandwidth for transfers

Specified by:
getMaxTransferRate in interface ProFTPClientInterface
Returns:
threshold bytes per second, or -1 if no threshold

mdelete

public void mdelete(java.lang.String wildcard)
             throws java.io.IOException,
                    FTPException,
                    java.text.ParseException
Description copied from interface: ProFTPClientInterface
Deletes all files matching the wildcard in the current remote directory only

Specified by:
mdelete in interface ProFTPClientInterface
Throws:
java.io.IOException
FTPException
java.text.ParseException

mdelete

public void mdelete(java.io.FileFilter filter)
             throws java.io.IOException,
                    FTPException,
                    java.text.ParseException
Description copied from interface: ProFTPClientInterface
Deletes all files matching the filter in the current remote directory only

Specified by:
mdelete in interface ProFTPClientInterface
Parameters:
filter - file filter
Throws:
java.io.IOException
FTPException
java.text.ParseException

mdelete

public void mdelete(java.lang.String remoteDir,
                    java.lang.String wildcard,
                    boolean recurse)
             throws java.io.IOException,
                    FTPException,
                    java.text.ParseException
Description copied from interface: ProFTPClientInterface
Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied wildcard. No directories are deleted. Only files matching the wildcard are deleted. On Windows clients, case is ignored.

Specified by:
mdelete in interface ProFTPClientInterface
Parameters:
remoteDir - name of remote directory
wildcard - filename wildcard
recurse - if true, recurse through subdirectories
Throws:
java.io.IOException
FTPException
java.text.ParseException

mdelete

public void mdelete(java.lang.String remoteDir,
                    java.io.FileFilter filter,
                    boolean recurse)
             throws java.io.IOException,
                    FTPException,
                    java.text.ParseException
Description copied from interface: ProFTPClientInterface
Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter. No directories are deleted. Only files matching the wildcard are deleted. On Windows clients, case is ignored.

Specified by:
mdelete in interface ProFTPClientInterface
Parameters:
remoteDir - name of remote directory
filter - filename filter
recurse - if true, recurse through subdirectories
Throws:
java.io.IOException
FTPException
java.text.ParseException

rmdir

public void rmdir(java.lang.String remoteDir,
                  boolean recurse)
           throws java.io.IOException,
                  FTPException,
                  java.text.ParseException
Description copied from interface: ProFTPClientInterface
Delete this remote directory. If recurse is true, delete all its contents, recursively going through subdirectories. If recurse is false and the directory contains files, an exception will be thrown

Specified by:
rmdir in interface ProFTPClientInterface
Parameters:
remoteDir - name of remote directory
recurse - if true, recurse through subdirectories
Throws:
java.io.IOException
FTPException
java.text.ParseException

mput

public void mput(java.lang.String localDir,
                 java.lang.String wildcard)
          throws java.io.IOException,
                 FTPException
Description copied from interface: ProFTPClientInterface
Put all files matching the wildcard in the supplied local directory only into the current remote directory

Specified by:
mput in interface ProFTPClientInterface
Parameters:
localDir - local directory to get files from
wildcard - filename wildcard
Throws:
java.io.IOException
FTPException

mput

public void mput(java.lang.String localDir,
                 java.io.FileFilter filter)
          throws java.io.IOException,
                 FTPException
Description copied from interface: ProFTPClientInterface
Put all files matching the wildcard in the supplied local directory only into the current remote directory

Specified by:
mput in interface ProFTPClientInterface
Parameters:
localDir - local directory to get files from
filter - filename filter
Throws:
java.io.IOException
FTPException

mput

public void mput(java.lang.String localDir,
                 java.lang.String remoteDir,
                 java.lang.String wildcard,
                 boolean recurse)
          throws FTPException,
                 java.io.IOException
Description copied from interface: ProFTPClientInterface
Puts this entire directory and its contents. If recurse is true, recursively go through the local directory supplied (which can be relative or absolute), including subdirectories. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name.

Specified by:
mput in interface ProFTPClientInterface
Parameters:
localDir - name of local directory
remoteDir - name of remote directory
wildcard - filename wildcard
recurse - if true recurse into subdirectories
Throws:
FTPException
java.io.IOException

mput

public void mput(java.lang.String localDir,
                 java.lang.String remoteDir,
                 java.io.FileFilter filter,
                 boolean recurse)
          throws FTPException,
                 java.io.IOException
Description copied from interface: ProFTPClientInterface
Puts this entire directory and its contents. If recurse is true, recursively go through the local directory supplied (which can be relative or absolute), including subdirectories. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name.

Specified by:
mput in interface ProFTPClientInterface
Parameters:
localDir - name of local directory
remoteDir - name of remote directory
filter - filename filter
recurse - if true recurse into subdirectories
Throws:
FTPException
java.io.IOException

mget

public void mget(java.lang.String localDir,
                 java.lang.String wildcard)
          throws java.io.IOException,
                 FTPException,
                 java.text.ParseException
Description copied from interface: ProFTPClientInterface
Get all files matching the filter in the current remote directory only into the supplied local directory

Specified by:
mget in interface ProFTPClientInterface
Parameters:
localDir - local directory to get files from
wildcard - filename wildcard
Throws:
java.io.IOException
FTPException
java.text.ParseException

mget

public void mget(java.lang.String localDir,
                 java.io.FileFilter filter)
          throws java.io.IOException,
                 FTPException,
                 java.text.ParseException
Description copied from interface: ProFTPClientInterface
Get all files matching the filter in the current remote directory only into the supplied local directory

Specified by:
mget in interface ProFTPClientInterface
Parameters:
localDir - local directory to get files from
filter - filename filter
Throws:
java.io.IOException
FTPException
java.text.ParseException

mget

public void mget(java.lang.String localDir,
                 java.lang.String remoteDir,
                 java.lang.String wildcard,
                 boolean recurse)
          throws FTPException,
                 java.io.IOException,
                 java.text.ParseException
Description copied from interface: ProFTPClientInterface
Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name

Specified by:
mget in interface ProFTPClientInterface
Parameters:
localDir - name of local directory we are transferring into
remoteDir - name of remote directory
wildcard - filename wildcard
recurse - if true recurse into subdirectories
Throws:
FTPException
java.io.IOException
java.text.ParseException

mget

public void mget(java.lang.String localDir,
                 java.lang.String remoteDir,
                 java.io.FileFilter filter,
                 boolean recurse)
          throws FTPException,
                 java.io.IOException,
                 java.text.ParseException
Description copied from interface: ProFTPClientInterface
Gets this entire remote directory and its contents, recursively going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name

Specified by:
mget in interface ProFTPClientInterface
Parameters:
localDir - name of local directory we are transferring into
remoteDir - name of remote directory
filter - filename filter
recurse - if true recurse into subdirectories
Throws:
FTPException
java.io.IOException
java.text.ParseException

getCountBeforeSleep

public int getCountBeforeSleep()
Description copied from interface: ProFTPClientInterface
Get the number of transfers set before sleeping

Specified by:
getCountBeforeSleep in interface ProFTPClientInterface
Returns:
integer

setCountBeforeSleep

public void setCountBeforeSleep(int countBeforeSleep)
Description copied from interface: ProFTPClientInterface
Set the number of transfers required before sleeping

Specified by:
setCountBeforeSleep in interface ProFTPClientInterface
Parameters:
countBeforeSleep - maximum transfer count

isSleepEnabled

public boolean isSleepEnabled()
Description copied from interface: ProFTPClientInterface
Is sleeping enabled?

Specified by:
isSleepEnabled in interface ProFTPClientInterface
Returns:
true if enabled

setSleepEnabled

public void setSleepEnabled(boolean sleepEnabled)
Description copied from interface: ProFTPClientInterface
Set sleeping enabled to be on or off

Specified by:
setSleepEnabled in interface ProFTPClientInterface
Parameters:
sleepEnabled - if true, sleeping is enabled, otherwise it is switched off

getSleepTime

public int getSleepTime()
Description copied from interface: ProFTPClientInterface
Get the number of seconds spent asleep

Specified by:
getSleepTime in interface ProFTPClientInterface
Returns:
integer

setSleepTime

public void setSleepTime(int sleepTime)
Description copied from interface: ProFTPClientInterface
Set the time spent asleep

Specified by:
setSleepTime in interface ProFTPClientInterface
Parameters:
sleepTime - sleep time in seconds


Copyright © 2001-2009 Enterprise Distributed Technologies Ltd. All Rights Reserved.