Class FTPClientWrapper
java.lang.Object
org.apache.commons.vfs2.provider.ftp.FTPClientWrapper
- All Implemented Interfaces:
- FtpClient
A wrapper to the FTPClient to allow automatic reconnect on connection loss.
 
I decided to not to use eg. noop() to determine the state of the connection to avoid unnecessary server round-trips.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedFTPClientWrapper(GenericFileName rootFileName, FileSystemOptions fileSystemOptions) Constructs a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionbooleanabort()Aborts the current operation.appendFileStream(String relPath) Returns an OutputStream through which data can be written to append to a file on the server with the given name.booleanThere are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction.protected org.apache.commons.net.ftp.FTPClientcreateClient(GenericFileName rootFileName, UserAuthenticationData authData) Creates an FTPClient.booleandeleteFile(String relPath) Deletes a file on the FTP server.voidSends the FTP QUIT command to the server, receive the reply, and return the reply code.Gets the FileSystemOptions.intGets the integer value of the reply code of the last FTP reply.Gets the entire text of the last FTP server response exactly as it was received, including all end of line markers in NETASCII format.getRoot()Gets the root file name.booleanhasFeature(String feature) Queries the server for a supported feature.booleanTests if the client is currently connected to a server.org.apache.commons.net.ftp.FTPFile[]Using the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.booleanmakeDirectory(String relPath) Creates a new subdirectory on the FTP server in the current directory (if a relative pathname is given) or where specified (if an absolute pathname is given).mdtmInstant(String relPath) Sends the MDTM command to get a file's date and time information after file transfer.booleanremoveDirectory(String relPath) Removes a directory on the FTP server (if empty).booleanRenames a remote file.retrieveFileStream(String relPath) Returns an InputStream from which a named file from the server can be read.retrieveFileStream(String relPath, int bufferSize) Returns an InputStream from which a named file from the server can be read.retrieveFileStream(String relPath, long restartOffset) Returns an InputStream from which a named file from the server can be read.voidsetBufferSize(int bufferSize) Sets the buffer size for buffered data streams.storeFileStream(String relPath) Returns an OutputStream through which data can be written to store a file on the server using the given name.
- 
Field Details- 
fileSystemOptionsAuthentication options.
 
- 
- 
Constructor Details- 
FTPClientWrapperprotected FTPClientWrapper(GenericFileName rootFileName, FileSystemOptions fileSystemOptions) throws FileSystemException Constructs a new instance.- Parameters:
- rootFileName- the root file name.
- fileSystemOptions- the file system options.
- Throws:
- FileSystemException- if a file system error occurs.
 
 
- 
- 
Method Details- 
abortDescription copied from interface:FtpClientAborts the current operation.- Specified by:
- abortin interface- FtpClient
- Returns:
- true if aborted.
- Throws:
- IOException- If an I/O error occurs
 
- 
appendFileStreamDescription copied from interface:FtpClientReturns an OutputStream through which data can be written to append to a file on the server with the given name.- Specified by:
- appendFileStreamin interface- FtpClient
- Parameters:
- relPath- The name of the remote file.
- Returns:
- An OutputStream through which the remote file can be appended.
- Throws:
- IOException- If an I/O error occurs.
 
- 
completePendingCommandDescription copied from interface:FtpClientThere are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction. These commands require some action by the programmer after the reception of a positive intermediate command. After the programmer's code completes its actions, it must call this method to receive the completion reply from the server and verify the success of the entire transaction.- Specified by:
- completePendingCommandin interface- FtpClient
- Returns:
- true if successfully completed, false if not.
- Throws:
- IOException- If an I/O error occurs.
 
- 
createClientprotected org.apache.commons.net.ftp.FTPClient createClient(GenericFileName rootFileName, UserAuthenticationData authData) throws FileSystemException Creates an FTPClient.- Parameters:
- rootFileName- the root file name.
- authData- authentication data.
- Returns:
- an FTPClient.
- Throws:
- FileSystemException- if a file system error occurs.
 
- 
deleteFileDescription copied from interface:FtpClientDeletes a file on the FTP server.- Specified by:
- deleteFilein interface- FtpClient
- Parameters:
- relPath- The relPath of the file to be deleted.
- Returns:
- true if successfully completed, false if not.
- Throws:
- IOException- If an I/O error occurs.
 
- 
disconnectDescription copied from interface:FtpClientSends the FTP QUIT command to the server, receive the reply, and return the reply code.- Specified by:
- disconnectin interface- FtpClient
- Throws:
- IOException- If an I/O error occurs.
 
- 
getFileSystemOptionsGets the FileSystemOptions.- Returns:
- the FileSystemOptions.
 
- 
getReplyCodeDescription copied from interface:FtpClientGets the integer value of the reply code of the last FTP reply.- Specified by:
- getReplyCodein interface- FtpClient
- Returns:
- The integer value of the reply code of the last FTP reply.
- Throws:
- IOException- If an I/O error occurs.
 
- 
getReplyStringDescription copied from interface:FtpClientGets the entire text of the last FTP server response exactly as it was received, including all end of line markers in NETASCII format.- Specified by:
- getReplyStringin interface- FtpClient
- Returns:
- The entire text from the last FTP response as a String.
- Throws:
- IOException- If an I/O error occurs.
 
- 
getRootGets the root file name.- Returns:
- the root file name.
 
- 
hasFeatureQueries the server for a supported feature.- Specified by:
- hasFeaturein interface- FtpClient
- Parameters:
- feature- the name of the feature, converted to upper case.
- Returns:
- trueif the feature is present,- falseif the feature is not present or the FTP command failed.
- Throws:
- IOException- If an I/O error occurs.
 
- 
isConnectedDescription copied from interface:FtpClientTests if the client is currently connected to a server.- Specified by:
- isConnectedin interface- FtpClient
- Returns:
- true if the client is currently connected to a server, false otherwise.
- Throws:
- FileSystemException- If an I/O error occurs.
 
- 
listFilesDescription copied from interface:FtpClientUsing the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.TODO This interface should not leak Apache Commons NET types like FTPFile - Specified by:
- listFilesin interface- FtpClient
- Parameters:
- relPath- The file or directory to list.
- Returns:
- an array of FTPFile.
- Throws:
- IOException- If an I/O error occurs.
 
- 
makeDirectoryDescription copied from interface:FtpClientCreates a new subdirectory on the FTP server in the current directory (if a relative pathname is given) or where specified (if an absolute pathname is given).- Specified by:
- makeDirectoryin interface- FtpClient
- Parameters:
- relPath- The pathname of the directory to create.
- Returns:
- true if successfully completed, false if not.
- Throws:
- IOException- If an I/O error occurs.
 
- 
mdtmInstantSends the MDTM command to get a file's date and time information after file transfer. It is typically more accurate than the"LIST"command response. Time values are always represented in UTC (GMT), and in the Gregorian calendar regardless of what calendar may have been in use at the date and time the file was last modified.NOTE: not all remote FTP servers support MDTM.- Specified by:
- mdtmInstantin interface- FtpClient
- Parameters:
- relPath- The relative path of the file object to execute- MDTMcommand against
- Returns:
- new Instantobject containing theMDTMtimestamp.
- Throws:
- IOException- If an I/O error occurs.
 
- 
removeDirectoryDescription copied from interface:FtpClientRemoves a directory on the FTP server (if empty).- Specified by:
- removeDirectoryin interface- FtpClient
- Parameters:
- relPath- The pathname of the directory to remove.
- Returns:
- true if successfully completed, false if not.
- Throws:
- IOException- If an I/O error occurs.
 
- 
renameDescription copied from interface:FtpClientRenames a remote file.- Specified by:
- renamein interface- FtpClient
- Parameters:
- oldName- The name of the remote file to rename.
- newName- The new name of the remote file.
- Returns:
- true if successfully completed, false if not.
- Throws:
- IOException- If an I/O error occurs.
 
- 
retrieveFileStreamDescription copied from interface:FtpClientReturns an InputStream from which a named file from the server can be read.- Specified by:
- retrieveFileStreamin interface- FtpClient
- Parameters:
- relPath- The name of the remote file.
- Returns:
- An InputStream from which the remote file can be read.
- Throws:
- IOException- If an I/O error occurs.
 
- 
retrieveFileStreamDescription copied from interface:FtpClientReturns an InputStream from which a named file from the server can be read.- Specified by:
- retrieveFileStreamin interface- FtpClient
- Parameters:
- relPath- The name of the remote file.
- bufferSize- buffer size.
- Returns:
- An InputStream from which the remote file can be read.
- Throws:
- IOException- If an I/O error occurs.
 
- 
retrieveFileStreamDescription copied from interface:FtpClientReturns an InputStream from which a named file from the server can be read.- Specified by:
- retrieveFileStreamin interface- FtpClient
- Parameters:
- relPath- The name of the remote file.
- restartOffset- restart offset.
- Returns:
- An InputStream from which the remote file can be read.
- Throws:
- IOException- If an I/O error occurs.
 
- 
setBufferSizeDescription copied from interface:FtpClientSets the buffer size for buffered data streams.- Specified by:
- setBufferSizein interface- FtpClient
- Parameters:
- bufferSize- The size of the buffer.
- Throws:
- FileSystemException- If an I/O error occurs.
 
- 
storeFileStreamDescription copied from interface:FtpClientReturns an OutputStream through which data can be written to store a file on the server using the given name.- Specified by:
- storeFileStreamin interface- FtpClient
- Parameters:
- relPath- The name to give the remote file.
- Returns:
- An OutputStream through which the remote file can be written.
- Throws:
- IOException- If an I/O error occurs.
 
 
-