Interface FtpClient

All Known Implementing Classes:
FTPClientWrapper

public interface FtpClient
What VFS expects from an FTP client to provide.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Aborts the current operation.
    Returns an OutputStream through which data can be written to append to a file on the server with the given name.
    boolean
    There are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction.
    boolean
    deleteFile(String relPath)
    Deletes a file on the FTP server.
    void
    Sends the FTP QUIT command to the server, receive the reply, and return the reply code.
    default int
    Gets 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.
    boolean
    hasFeature(String feature)
    Queries the server for a supported feature.
    boolean
    Tests if the client is currently connected to a server.
    org.apache.commons.net.ftp.FTPFile[]
    listFiles(String relPath)
    Using the default system autodetect mechanism, obtain a list of file information for the current working directory or for just a single file.
    boolean
    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).
    default Instant
    Sends the MDTM command to get a file's date and time information after file transfer.
    boolean
    Removes a directory on the FTP server (if empty).
    boolean
    rename(String from, String to)
    Renames a remote file.
    Returns an InputStream from which a named file from the server can be read.
    default InputStream
    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.
    default void
    setBufferSize(int bufferSize)
    Sets the buffer size for buffered data streams.
    Returns an OutputStream through which data can be written to store a file on the server using the given name.
  • Method Details

    • abort

      boolean abort() throws IOException
      Aborts the current operation.
      Returns:
      true if aborted.
      Throws:
      IOException - If an I/O error occurs
    • appendFileStream

      Returns an OutputStream through which data can be written to append to a file on the server with the given name.
      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.
    • completePendingCommand

      There 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.
      Returns:
      true if successfully completed, false if not.
      Throws:
      IOException - If an I/O error occurs.
    • deleteFile

      boolean deleteFile(String relPath) throws IOException
      Deletes a file on the FTP server.
      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.
    • disconnect

      void disconnect() throws IOException
      Sends the FTP QUIT command to the server, receive the reply, and return the reply code.
      Throws:
      IOException - If an I/O error occurs.
    • getReplyCode

      default int getReplyCode() throws IOException
      Gets the integer value of the reply code of the last FTP reply.
      Returns:
      The integer value of the reply code of the last FTP reply.
      Throws:
      IOException - If an I/O error occurs.
    • getReplyString

      Gets the entire text of the last FTP server response exactly as it was received, including all end of line markers in NETASCII format.
      Returns:
      The entire text from the last FTP response as a String.
      Throws:
      IOException - If an I/O error occurs.
    • hasFeature

      boolean hasFeature(String feature) throws IOException
      Queries the server for a supported feature.
      Parameters:
      feature - the name of the feature, converted to upper case.
      Returns:
      true if the feature is present, false if the feature is not present or the FTP command failed.
      Throws:
      IOException - If an I/O error occurs.
      Since:
      2.8.0
    • isConnected

      Tests if the client is currently connected to a server.
      Returns:
      true if the client is currently connected to a server, false otherwise.
      Throws:
      FileSystemException - If an I/O error occurs.
    • listFiles

      org.apache.commons.net.ftp.FTPFile[] listFiles(String relPath) throws IOException
      Using 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

      Parameters:
      relPath - The file or directory to list.
      Returns:
      an array of FTPFile.
      Throws:
      IOException - If an I/O error occurs.
    • makeDirectory

      boolean makeDirectory(String relPath) throws IOException
      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).
      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.
    • mdtmInstant

      default Instant mdtmInstant(String relPath) throws IOException
      Sends 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.

      Parameters:
      relPath - The relative path of the file object to execute MDTM command against
      Returns:
      new Instant object containing the MDTM timestamp.
      Throws:
      IOException - If an I/O error occurs.
      Since:
      2.8.0
    • removeDirectory

      boolean removeDirectory(String relPath) throws IOException
      Removes a directory on the FTP server (if empty).
      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.
    • rename

      boolean rename(String from, String to) throws IOException
      Renames a remote file.
      Parameters:
      from - The name of the remote file to rename.
      to - The new name of the remote file.
      Returns:
      true if successfully completed, false if not.
      Throws:
      IOException - If an I/O error occurs.
    • retrieveFileStream

      Returns an InputStream from which a named file from the server can be read.
      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.
    • retrieveFileStream

      default InputStream retrieveFileStream(String relPath, int bufferSize) throws IOException
      Returns an InputStream from which a named file from the server can be read.
      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.
    • retrieveFileStream

      InputStream retrieveFileStream(String relPath, long restartOffset) throws IOException
      Returns an InputStream from which a named file from the server can be read.
      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.
    • setBufferSize

      default void setBufferSize(int bufferSize) throws FileSystemException
      Sets the buffer size for buffered data streams.
      Parameters:
      bufferSize - The size of the buffer.
      Throws:
      FileSystemException - If an I/O error occurs.
    • storeFileStream

      Returns an OutputStream through which data can be written to store a file on the server using the given name.
      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.