Package com.enterprisedt.net.ftp
Class RecursiveOperations
java.lang.Object
com.enterprisedt.net.ftp.RecursiveOperations
Performs various recursive FTP operations. Some operations permit a wildcard
string to be supplied for matching filenames (directories are not matched
against the wildcard). The syntax used is '?' for single chars and '*' for
multiple chars, e.g. 'asdf??df*abc' would match 'asdfxydfdsfsjfkj33abc'. On
Windows clients, case is ignored.
Note that if there are a large number of files to be transferred, the client or server may run out of sockets, as a new socket is created for each data transfer and each directory listing. TCP's TIME_WAIT means that sockets are not reclaimed immediately. If sleeping is enabled via setSleepEnabled(true), then Thread.sleep() is called after n transfers, where n is set by setCountBeforeSleep(n). The time spent asleep is set via setSleepTime().
- Version:
- $Revision$
- Author:
- Bruce Blackshaw
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddelete(FTPClientInterface ftp, String remoteDir) Delete this entire remote directory and its contents, recursively going through the remote directory name suppliedvoiddeleteFiles(FTPClientInterface ftp, FileFilter filter, boolean recurse) Delete all the files in the current directory (and its subdirectories if indicated) that match the supplied filter, recursively going through the remote directories.voiddeleteFiles(FTPClientInterface ftp, String remoteDir, FileFilter filter) Delete all the files in this directory (and its subdirectories) that match the supplied filter, recursively going through the remote directories.voiddeleteFiles(FTPClientInterface ftp, 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, recursively going through the remote directories.voiddeleteFiles(FTPClientInterface ftp, String remoteDir, String wildcard) Delete all the files in this directory (and its subdirectories) that match the supplied wildcard, recursively going through the remote directories.voiddeleteFilesCurrentDir(FTPClientInterface ftp, FileFilter filter) Delete all the files in this directory (not subdirectories) that match the supplied filter.FTPFile[]dirDetails(FTPClientInterface ftp, String remoteDir) List this entire remote directory and its contents, including children.voidget(FTPClientInterface ftp, String localDir, String remoteDir) Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.voidget(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter) Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.voidget(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter, boolean recurse) Gets this entire remote directory and its contents, recursively (if recurse is true) going through the remote directory name supplied.voidget(FTPClientInterface ftp, String localDir, String remoteDir, String wildcard) Gets this entire remote directory and its contents, recursively going through the remote directory name supplied.intGet the number of transfers set before sleepingvoidgetFilesFromCurrentDir(FTPClientInterface ftp, String localDir, FileFilter filter) Gets all files matching the supplied filter from current remote directory into supplied local dir.intGet the number of seconds spent asleepbooleanIs sleeping enabled?voidput(FTPClientInterface ftp, String localDir, String remoteDir) Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute.voidput(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter) Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute.voidput(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter, boolean recurse) Puts this entire directory and its contents.voidput(FTPClientInterface ftp, String localDir, String remoteDir, String wildcard) Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute.voidputFilesIntoCurrentDir(FTPClientInterface ftp, String localDir, FileFilter filter) Puts all files from supplied local dir matching the supplied filter into the current remote directory.voidsetCountBeforeSleep(int countBeforeSleep) Set the number of transfers required before sleepingvoidsetSleepEnabled(boolean sleepEnabled) Set sleeping enabled to be on or offvoidsetSleepTime(int sleepTime) Set the time spent asleep
-
Field Details
-
cvsId
Revision control id
-
-
Constructor Details
-
RecursiveOperations
public RecursiveOperations()
-
-
Method Details
-
getCountBeforeSleep
public int getCountBeforeSleep()Get the number of transfers set before sleeping- Returns:
- integer
-
setCountBeforeSleep
public void setCountBeforeSleep(int countBeforeSleep) Set the number of transfers required before sleeping- Parameters:
countBeforeSleep- maximum transfer count
-
isSleepEnabled
public boolean isSleepEnabled()Is sleeping enabled?- Returns:
- true if enabled
-
setSleepEnabled
public void setSleepEnabled(boolean sleepEnabled) Set sleeping enabled to be on or off- Parameters:
sleepEnabled- if true, sleeping is enabled, otherwise it is switched off
-
getSleepTime
public int getSleepTime()Get the number of seconds spent asleep- Returns:
- integer
-
setSleepTime
public void setSleepTime(int sleepTime) Set the time spent asleep- Parameters:
sleepTime- sleep time in seconds
-
dirDetails
public FTPFile[] dirDetails(FTPClientInterface ftp, String remoteDir) throws IOException, FTPException, ParseException List this entire remote directory and its contents, including children.- Parameters:
ftp- the FTP client referenceremoteDir- name of remote directory- Throws:
IOExceptionFTPExceptionParseException
-
delete
public void delete(FTPClientInterface ftp, String remoteDir) throws IOException, FTPException, ParseException Delete this entire remote directory and its contents, recursively going through the remote directory name supplied- Parameters:
ftp- the FTP client referenceremoteDir- name of remote directory- Throws:
IOExceptionFTPExceptionParseException
-
deleteFilesCurrentDir
public void deleteFilesCurrentDir(FTPClientInterface ftp, FileFilter filter) throws IOException, FTPException, ParseException Delete all the files in this directory (not subdirectories) that match the supplied filter. Only files matching the filter are deleted. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencefilter- filename filter- Throws:
IOExceptionFTPExceptionParseException
-
deleteFiles
public void deleteFiles(FTPClientInterface ftp, String remoteDir, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException Delete all the files in this directory (and its subdirectories if recurse is true) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referenceremoteDir- name of remote directoryfilter- filename filterrecurse- true if recursing through subdirectories- Throws:
IOExceptionFTPExceptionParseException
-
deleteFiles
public void deleteFiles(FTPClientInterface ftp, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException Delete all the files in the current directory (and its subdirectories if indicated) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencefilter- filename filterrecurse- true if recursing through subdirectories- Throws:
IOExceptionFTPExceptionParseException
-
deleteFiles
public void deleteFiles(FTPClientInterface ftp, String remoteDir, FileFilter filter) throws IOException, FTPException, ParseException Delete all the files in this directory (and its subdirectories) that match the supplied filter, recursively going through the remote directories. No directories are deleted. Only files matching the filter are deleted. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referenceremoteDir- name of remote directoryfilter- filename filter- Throws:
IOExceptionFTPExceptionParseException
-
deleteFiles
public void deleteFiles(FTPClientInterface ftp, String remoteDir, String wildcard) throws IOException, FTPException, ParseException Delete all the files in this directory (and its subdirectories) that match the supplied wildcard, recursively going through the remote directories. No directories are deleted. Only files matching the wildcard are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referenceremoteDir- name of remote directorywildcard- wildcard for filename matching- Throws:
IOExceptionFTPExceptionParseException
-
getFilesFromCurrentDir
public void getFilesFromCurrentDir(FTPClientInterface ftp, String localDir, FileFilter filter) throws IOException, FTPException, ParseException Gets all files matching the supplied filter from current remote directory into supplied local dir. No directories are retrieved.- Parameters:
ftp- the FTP client referencelocalDir- name of local directory to get files intofilter- filename filter- Throws:
IOExceptionFTPExceptionParseException
-
get
public void get(FTPClientInterface ftp, String localDir, String remoteDir) throws IOException, FTPException, ParseException 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- Parameters:
ftp- the FTP client referencelocalDir- name of local directory we are transferring intoremoteDir- name of remote directory- Throws:
IOExceptionFTPExceptionParseException
-
get
public void get(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter) throws IOException, FTPException, ParseException 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. Only files matching the filter are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencelocalDir- name of local directory we are transferring intoremoteDir- name of remote directoryfilter- filename filter- Throws:
IOExceptionFTPExceptionParseException
-
get
public void get(FTPClientInterface ftp, String localDir, String remoteDir, String wildcard) throws IOException, FTPException, ParseException 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. Only files matching the wildcard are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencelocalDir- name of local directory we are transferring intoremoteDir- name of remote directorywildcard- wildcard for filename matching- Throws:
IOExceptionFTPExceptionParseException
-
get
public void get(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter, boolean recurse) throws IOException, FTPException, ParseException Gets this entire remote directory and its contents, recursively (if recurse is true) going through the remote directory name supplied. Gets the directory into the current local directory, into a directory with supplied localDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencelocalDir- name of local directory we are transferring intoremoteDir- name of remote directoryfilter- filename filterrecurse- if true recurse through subdirectories- Throws:
IOExceptionFTPExceptionParseException
-
putFilesIntoCurrentDir
public void putFilesIntoCurrentDir(FTPClientInterface ftp, String localDir, FileFilter filter) throws FTPException, IOException Puts all files from supplied local dir matching the supplied filter into the current remote directory. No directories are put.- Parameters:
ftp- the FTP client referencelocalDir- name of local directory- Throws:
FTPExceptionIOException
-
put
public void put(FTPClientInterface ftp, String localDir, String remoteDir) throws FTPException, IOException Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name.- Parameters:
ftp- the FTP client referencelocalDir- name of local directoryremoteDir- name of remote directory- Throws:
FTPExceptionIOException
-
put
public void put(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter) throws FTPException, IOException Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencelocalDir- name of local directoryremoteDir- name of remote directoryfilter- filename filter- Throws:
FTPExceptionIOException
-
put
public void put(FTPClientInterface ftp, String localDir, String remoteDir, String wildcard) throws FTPException, IOException Puts this entire directory and its contents, recursively going through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the wildcard are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencelocalDir- name of local directoryremoteDir- name of remote directorywildcard- wildcard for filename matching- Throws:
FTPExceptionIOException
-
put
public void put(FTPClientInterface ftp, String localDir, String remoteDir, FileFilter filter, boolean recurse) throws FTPException, IOException Puts this entire directory and its contents. If recurse is true, it recursively goes through the local directory supplied (which can be relative or absolute. Puts the directory into the current remote directory, into a directory with the supplied remoteDir name. Only files matching the filter are fetched. On Windows clients, case is ignored.- Parameters:
ftp- the FTP client referencelocalDir- name of local directoryremoteDir- name of remote directory, or null if the current remote directoryfilter- filename filter- Throws:
FTPExceptionIOException
-