Package com.enterprisedt.net.ftp.pro
Class ProFTPClient
java.lang.Object
com.enterprisedt.net.ftp.FTPClient
com.enterprisedt.net.ftp.pro.ProFTPClient
- All Implemented Interfaces:
FTPClientInterface,ProFTPClientInterface
- Direct Known Subclasses:
SSLFTPClient
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$
- Author:
- Bruce Blackshaw
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringRevision control idprotected ProxySettingsThe proxy settingsFields 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_TCP_BUFFER_SIZE, DEFAULT_TIMEOUT, detectTransferMode, dirEmptyStrings, fileLockingEnabled, fileNotFoundStrings, FTP_LINE_SEPARATOR, id, lastReply, lastValidReply, LINE_FEED, LINE_SEPARATOR, messageListener, monitor, monitorEx, monitorInterval, password, remoteAddr, remoteHost, serverWakeupInterval, throttler, timeout, transferBufferSize, transferCompleteStrings, transferType, useNOOP, user -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidconnect()Connects to the server at the address and port number defined in the constructor.voidSet MODE Z so that all subsequent transfers are compressedintGet the number of transfers set before sleepingprotected InputStreamGet the data input stream.intgetLocalCRC(byte[] bytes) Get the CRC-32 checksum for the supplied byte arrayintgetLocalCRC(String path) Get the CRC-32 checksum for the named local file.intGet the maximum bandwidth for transfersprotected OutputStreamGet the data input stream.Get the proxy settings instance.getRemoteCRC(String path) Get the CRC-32 checksum for the named remote file.intGet the number of seconds spent asleepprotected voidintegrityCheckTransferCRC(byte[] localBytes, String remoteFile) protected voidintegrityCheckTransferCRC(String localPath, String remoteFile) protected voidintegrityCheckTransferSize(long length, String remoteFile) booleanAre we in mode z currently?booleanIs sleeping enabled?booleanIs integrity checking of transfers enabled?voidmdelete(FileFilter filter) Deletes all files matching the filter in the current remote directory onlyvoidDeletes all files matching the wildcard in the current remote directory onlyvoidmdelete(String remoteDir, FileFilter filter, boolean recurse) Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter.voidDelete all the files in this directory (and its subdirectories if recurse is true) that match the supplied wildcard.voidmget(String localDir, FileFilter filter) Get all files matching the filter in the current remote directory only into the supplied local directoryvoidGet all files matching the filter in the current remote directory only into the supplied local directoryvoidmget(String localDir, String remoteDir, FileFilter filter, boolean recurse) Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.voidGets this entire remote directory and its contents, recursively going through the remote directory name supplied.voidmput(String localDir, FileFilter filter) Put all files matching the wildcard in the supplied local directory only into the current remote directoryvoidPut all files matching the wildcard in the supplied local directory only into the current remote directoryvoidmput(String localDir, String remoteDir, FileFilter filter, boolean recurse) Puts this entire directory and its contents.voidPuts this entire directory and its contents.protected voidpostTransferChecks(byte[] localBytes, String remotePath, FTPTransferType type, boolean append) Can be overridden by subclasses to do any necessary post transfer checking.protected voidpostTransferChecks(String localPath, String remotePath, FTPTransferType type, boolean append) Can be overridden by subclasses to do any necessary post transfer checking.voidDelete this remote directory.voidsetCountBeforeSleep(int countBeforeSleep) Set the number of transfers required before sleepingvoidsetMaxTransferRate(int thresholdBytesPerSecond) Set the maximum transfer rates in bytes per secvoidsetSleepEnabled(boolean sleepEnabled) Set sleeping enabled to be on or offvoidsetSleepTime(int sleepTime) Set the time spent asleepvoidsetTransferIntegrityCheck(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, configureDataSocket, connected, createDataSocket, debugResponses, delete, dir, dir, dir, dirDetails, dirDetails, dirDetailsM, executeCommand, exists, existsDirectory, existsFile, features, fileDetails, forceResumeOff, get, get, get, getActiveHighPort, getActiveIPAddress, getActiveLowPort, getBuildTimestamp, getConnectMode, getControlEncoding, getControlPort, getDataReceiveBufferSize, getDataSendBufferSize, getDeleteCount, getDetectTransferMode, getDirectoryEmptyMessages, getDownloadCount, getFileLockingEnabled, getFileNotFoundMessages, getId, getLastReply, getLastValidReply, getListenOnAllInterfaces, getMessageListener, getMonitorInterval, getNetworkBufferSize, 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, noOp, noOperation, password, put, put, put, put, put, put, pwd, quit, quitImmediately, quote, quote, readChar, readChunk, readChunk, readLine, reconnect, rename, resetDeleteCount, resetDownloadCount, resetTransferMode, resetUploadCount, restart, resume, resumeNextDownload, rmdir, sendCommand, sendServerWakeup, setActiveIPAddress, setActivePortRange, setAutoPassiveIPSubstitution, setConnectMode, setControlEncoding, setControlPort, setDataChannelCallback, setDataReceiveBufferSize, setDataSendBufferSize, setDeleteOnFailure, setDetectTransferMode, setDirectoryEmptyMessages, setFileLockingEnabled, setFileNotFoundMessages, setForceUniqueNames, setFTPFileFactory, setId, setListenOnAllInterfaces, setMessageListener, setModTime, setMonitorInterval, setNetworkBufferSize, setParserLocale, setParserLocales, setPORTIP, setProgressMonitor, setProgressMonitor, setProgressMonitorEx, setRemoteAddr, setRemoteHost, setRemotePort, setRetryCount, setRetryDelay, setServerWakeupInterval, setStrictReturnCodes, setTimeout, setTransferBufferSize, setTransferCompleteMessages, setType, site, size, stat, system, toString, user, validateReply, validateReply, validateTransfer, validateTransferOnErrorMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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, getFileLockingEnabled, getId, getMonitorInterval, getNetworkBufferSize, getRemoteHost, getRemotePort, getTimeout, getType, getUploadCount, keepAlive, mkdir, modtime, put, put, put, put, put, put, pwd, quit, quitImmediately, rename, resetDeleteCount, resetDownloadCount, resetUploadCount, resume, resumeNextDownload, rmdir, setControlEncoding, setDetectTransferMode, setFileLockingEnabled, setId, setModTime, setNetworkBufferSize, setProgressMonitor, setProgressMonitor, setRemoteHost, setRemotePort, setTimeout, setType, size, systemMethods inherited from interface com.enterprisedt.net.ftp.pro.ProFTPClientInterface
getProgressMonitorEx, setMonitorInterval, setProgressMonitorEx
-
Field Details
-
cvsId
Revision control id- See Also:
-
proxySettings
The proxy settings
-
-
Constructor Details
-
ProFTPClient
public ProFTPClient()Default constructor. TheFTPClient.connect()method is used to perform the actual connection to the remote host.
-
-
Method Details
-
getProxySettings
Get the proxy settings instance. Its properties can be set to use proxies.- Specified by:
getProxySettingsin interfaceProFTPClientInterface- Returns:
- ProxySettings
-
connect
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:
connectin interfaceFTPClientInterface- Overrides:
connectin classFTPClient- Throws:
IOException- Thrown if there is a TCP/IP-related error.FTPException- Thrown if there is an error related to the FTP protocol.
-
enableModeZCompression
Set MODE Z so that all subsequent transfers are compressed- Throws:
IOExceptionFTPException
-
getLocalCRC
Get the CRC-32 checksum for the named local file.- Parameters:
path- local file path- Throws:
FTPExceptionIOException
-
getLocalCRC
Get the CRC-32 checksum for the supplied byte array- Parameters:
bytes- byte array- Throws:
FTPExceptionIOException
-
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
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:
FTPExceptionIOException
-
postTransferChecks
protected void postTransferChecks(String localPath, String remotePath, FTPTransferType type, boolean append) throws FTPException, IOException Can be overridden by subclasses to do any necessary post transfer checking.- Overrides:
postTransferChecksin classFTPClient- Parameters:
localPath- local fileremotePath- remote filetype- binary or ASCIIappend-- Throws:
IOExceptionFTPException
-
integrityCheckTransferCRC
protected void integrityCheckTransferCRC(String localPath, String remoteFile) throws IOException, FTPException - Throws:
IOExceptionFTPException
-
integrityCheckTransferCRC
protected void integrityCheckTransferCRC(byte[] localBytes, String remoteFile) throws IOException, FTPException - Throws:
IOExceptionFTPException
-
integrityCheckTransferSize
protected void integrityCheckTransferSize(long length, String remoteFile) throws IOException, FTPException - Throws:
IOExceptionFTPException
-
postTransferChecks
protected void postTransferChecks(byte[] localBytes, String remotePath, FTPTransferType type, boolean append) throws FTPException, IOException Can be overridden by subclasses to do any necessary post transfer checking.- Overrides:
postTransferChecksin classFTPClient- Parameters:
localBytes- local bytes to transferremotePath- remote filetype- binary or ASCIIappend-transferType- binary or ASCII- Throws:
FTPExceptionIOException
-
getInputStream
Get the data input stream. Not for general use!- Overrides:
getInputStreamin classFTPClient- Returns:
- Throws:
IOException
-
getOutputStream
Get the data input stream. Not for general use!- Overrides:
getOutputStreamin classFTPClient- Returns:
- Throws:
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:
setMaxTransferRatein interfaceProFTPClientInterface- Parameters:
thresholdBytesPerSecond- maximum bytes per second to transfer
-
getMaxTransferRate
public int getMaxTransferRate()Get the maximum bandwidth for transfers- Specified by:
getMaxTransferRatein interfaceProFTPClientInterface- Returns:
- threshold bytes per second, or -1 if no threshold
-
mdelete
Description copied from interface:ProFTPClientInterfaceDeletes all files matching the wildcard in the current remote directory only- Specified by:
mdeletein interfaceProFTPClientInterface- Parameters:
wildcard-- Throws:
IOExceptionFTPExceptionParseException
-
mdelete
Description copied from interface:ProFTPClientInterfaceDeletes all files matching the filter in the current remote directory only- Specified by:
mdeletein interfaceProFTPClientInterface- Parameters:
filter- file filter- Throws:
IOExceptionFTPExceptionParseException
-
mdelete
public void mdelete(String remoteDir, String wildcard, boolean recurse) throws IOException, FTPException, ParseException Description copied from interface:ProFTPClientInterfaceDelete 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:
mdeletein interfaceProFTPClientInterface- Parameters:
remoteDir- name of remote directorywildcard- filename wildcardrecurse- if true, recurse through subdirectories- Throws:
IOExceptionFTPExceptionParseException
-
mdelete
public void mdelete(String remoteDir, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException Description copied from interface:ProFTPClientInterfaceDelete 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:
mdeletein interfaceProFTPClientInterface- Parameters:
remoteDir- name of remote directoryfilter- filename filterrecurse- if true, recurse through subdirectories- Throws:
IOExceptionFTPExceptionParseException
-
rmdir
public void rmdir(String remoteDir, boolean recurse) throws IOException, FTPException, ParseException Description copied from interface:ProFTPClientInterfaceDelete 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:
rmdirin interfaceProFTPClientInterface- Parameters:
remoteDir- name of remote directoryrecurse- if true, recurse through subdirectories- Throws:
IOExceptionFTPExceptionParseException
-
mput
Description copied from interface:ProFTPClientInterfacePut all files matching the wildcard in the supplied local directory only into the current remote directory- Specified by:
mputin interfaceProFTPClientInterface- Parameters:
localDir- local directory to get files fromwildcard- filename wildcard- Throws:
IOExceptionFTPException
-
mput
Description copied from interface:ProFTPClientInterfacePut all files matching the wildcard in the supplied local directory only into the current remote directory- Specified by:
mputin interfaceProFTPClientInterface- Parameters:
localDir- local directory to get files fromfilter- filename filter- Throws:
IOExceptionFTPException
-
mput
public void mput(String localDir, String remoteDir, String wildcard, boolean recurse) throws FTPException, IOException Description copied from interface:ProFTPClientInterfacePuts 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:
mputin interfaceProFTPClientInterface- Parameters:
localDir- name of local directoryremoteDir- name of remote directorywildcard- filename wildcardrecurse- if true recurse into subdirectories- Throws:
FTPExceptionIOException
-
mput
public void mput(String localDir, String remoteDir, FileFilter filter, boolean recurse) throws FTPException, IOException Description copied from interface:ProFTPClientInterfacePuts 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:
mputin interfaceProFTPClientInterface- Parameters:
localDir- name of local directoryremoteDir- name of remote directoryfilter- filename filterrecurse- if true recurse into subdirectories- Throws:
FTPExceptionIOException
-
mget
Description copied from interface:ProFTPClientInterfaceGet all files matching the filter in the current remote directory only into the supplied local directory- Specified by:
mgetin interfaceProFTPClientInterface- Parameters:
localDir- local directory to get files fromwildcard- filename wildcard- Throws:
IOExceptionFTPExceptionParseException
-
mget
public void mget(String localDir, FileFilter filter) throws IOException, FTPException, ParseException Description copied from interface:ProFTPClientInterfaceGet all files matching the filter in the current remote directory only into the supplied local directory- Specified by:
mgetin interfaceProFTPClientInterface- Parameters:
localDir- local directory to get files fromfilter- filename filter- Throws:
IOExceptionFTPExceptionParseException
-
mget
public void mget(String localDir, String remoteDir, String wildcard, boolean recurse) throws FTPException, IOException, ParseException Description copied from interface:ProFTPClientInterfaceGets 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:
mgetin interfaceProFTPClientInterface- Parameters:
localDir- name of local directory we are transferring intoremoteDir- name of remote directorywildcard- filename wildcardrecurse- if true recurse into subdirectories- Throws:
FTPExceptionIOExceptionParseException
-
mget
public void mget(String localDir, String remoteDir, FileFilter filter, boolean recurse) throws FTPException, IOException, ParseException Description copied from interface:ProFTPClientInterfaceGets 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:
mgetin interfaceProFTPClientInterface- Parameters:
localDir- name of local directory we are transferring intoremoteDir- name of remote directoryfilter- filename filterrecurse- if true recurse into subdirectories- Throws:
FTPExceptionIOExceptionParseException
-
getCountBeforeSleep
public int getCountBeforeSleep()Description copied from interface:ProFTPClientInterfaceGet the number of transfers set before sleeping- Specified by:
getCountBeforeSleepin interfaceProFTPClientInterface- Returns:
- integer
-
setCountBeforeSleep
public void setCountBeforeSleep(int countBeforeSleep) Description copied from interface:ProFTPClientInterfaceSet the number of transfers required before sleeping- Specified by:
setCountBeforeSleepin interfaceProFTPClientInterface- Parameters:
countBeforeSleep- maximum transfer count
-
isSleepEnabled
public boolean isSleepEnabled()Description copied from interface:ProFTPClientInterfaceIs sleeping enabled?- Specified by:
isSleepEnabledin interfaceProFTPClientInterface- Returns:
- true if enabled
-
setSleepEnabled
public void setSleepEnabled(boolean sleepEnabled) Description copied from interface:ProFTPClientInterfaceSet sleeping enabled to be on or off- Specified by:
setSleepEnabledin interfaceProFTPClientInterface- Parameters:
sleepEnabled- if true, sleeping is enabled, otherwise it is switched off
-
getSleepTime
public int getSleepTime()Description copied from interface:ProFTPClientInterfaceGet the number of seconds spent asleep- Specified by:
getSleepTimein interfaceProFTPClientInterface- Returns:
- integer
-
setSleepTime
public void setSleepTime(int sleepTime) Description copied from interface:ProFTPClientInterfaceSet the time spent asleep- Specified by:
setSleepTimein interfaceProFTPClientInterface- Parameters:
sleepTime- sleep time in seconds
-