Interface FileTransferClientInterface

All Known Implementing Classes:
AsyncFileTransferClient, FileTransferClient, SecureFileTransferClient

public interface FileTransferClientInterface
Easy to use FTP client interface
Version:
$Revision$
Author:
Bruce Blackshaw
  • Method Details

    • isConnected

      boolean isConnected()
      Is this client currently connected to the server?
      Returns:
      true if connected, false otherwise
    • getRemoteHost

      String getRemoteHost()
      Returns the IP address or name of the remote host.
      Returns:
      Returns the remote host.
    • setRemoteHost

      void setRemoteHost(String remoteHost) throws FTPException
      Set the IP address or name of the remote host This may only be done if the client is not already connected to the server.
      Parameters:
      remoteHost - The IP address or name of the remote host
      Throws:
      FTPException - Thrown if the client is already connected to the server.
    • getTimeout

      int getTimeout()
      Returns the timeout for socket connections.
      Returns:
      Returns the connection timeout in milliseconds
    • setTimeout

      void setTimeout(int timeout) throws FTPException
      Set the timeout for socket connections. Can only do this if not already connected.
      Parameters:
      timeout - the timeout to use in milliseconds
      Throws:
      FTPException - Thrown if the client is already connected to the server.
    • getNetworkBufferSize

      int getNetworkBufferSize()
      Get the size of the network buffers (SO_SNDBUF and SO_RCVBUF).
      Returns:
      network buffer size
    • setNetworkBufferSize

      void setNetworkBufferSize(int networkBufferSize) throws FTPException
      Set the size of the network buffers (SO_SNDBUF and SO_RCVBUF).
      Parameters:
      networkBufferSize - new buffer size to set
      Throws:
      FTPException
    • getRemotePort

      int getRemotePort()
      Returns the port being connected to on the remote server.
      Returns:
      Returns the port being connected to on the remote server.
    • setRemotePort

      void setRemotePort(int remotePort) throws FTPException
      Set the port to connect to on the remote server. Can only do this if not already connected.
      Parameters:
      remotePort - The port to use.
      Throws:
      FTPException - Thrown if the client is already connected to the server.
    • setContentType

      void setContentType(FTPTransferType type) throws IOException, FTPException
      Set the transfer type for all connections, either ASCII or binary. Setting applies to all subsequent transfers that are initiated.
      Parameters:
      type - transfer type
      Throws:
      FTPException
      IOException
      FTPException
    • getContentType

      FTPTransferType getContentType()
      Get the current content type for all connections.
      Returns:
      transfer type
    • setDetectContentType

      void setDetectContentType(boolean detectContentType)
      Set auto detect of filetypes on or off. If on, the transfer mode is switched from ASCII to binary and vice versa depending on the extension of the file. After the transfer, the mode is always returned to what it was before the transfer was performed. The default is off. If the filetype is unknown, the transfer mode is unchanged
      Parameters:
      detectContentType - true if detecting content type, false if not
    • isDetectContentType

      boolean isDetectContentType()
      Get the detect content type flag
      Returns:
      true if we are detecting binary and ASCII transfers from the file type
    • setUserName

      void setUserName(String userName) throws FTPException
      Set the name of the user to log in with. Can only do this if not already connected.
      Parameters:
      userName - user-name to log in with.
      Throws:
      FTPException
    • getPassword

      String getPassword()
      Get the current user password.
      Returns:
      current user password
    • setPassword

      void setPassword(String password) throws FTPException
      Set the password of the user to log in with. Can only do this if not already connected.
      Parameters:
      password - password to log in with.
      Throws:
      FTPException
    • getUserName

      String getUserName()
      Get the current user name.
      Returns:
      current user name
    • getAdvancedFTPSettings

      AdvancedFTPSettings getAdvancedFTPSettings()
      Get the advanced FTP configuration parameters object
      Returns:
      advanced parameters
    • getAdvancedSettings

      AdvancedGeneralSettings getAdvancedSettings()
      Get the advanced general configuration parameters object
      Returns:
      advanced parameters
    • setEventListener

      void setEventListener(EventListener listener)
      Set the event listener for transfer event notification
      Parameters:
      listener - event listener reference
    • connect

      void connect() throws FTPException, IOException
      Make a connection to the FTP server.
      Throws:
      FTPException
      IOException
    • getStatistics

      FileStatistics getStatistics()
      Get statistics on file transfers and deletions.
      Returns:
      FTPStatistics
    • executeCommand

      String executeCommand(String command) throws FTPException, IOException
      Request that the remote server execute the literal command supplied. In FTP, this is the equivalent of 'quote'. It could be used to send a SITE command to the server, e.g. "SITE recfm=FB lrecl=180 blksize=5400".
      Parameters:
      command - command string
      Returns:
      result string returned by server
      Throws:
      FTPException
      IOException
    • cancelAllTransfers

      void cancelAllTransfers()
      Cancel current transfer if underway
    • getSystemType

      String getSystemType() throws FTPException, IOException
      Get a string that represents the remote system that the client is logged into.
      Returns:
      system string
      Throws:
      FTPException
      IOException
    • directoryNameList

      String[] directoryNameList() throws FTPException, IOException
      List the names of files and directories in the current directory on the FTP server.
      Returns:
      String[]
      Throws:
      FTPException
      IOException
    • directoryNameList

      String[] directoryNameList(String directoryName, boolean isLongListing) throws FTPException, IOException
      List the names of files and directories of a directory on the FTP server.
      Parameters:
      directoryName - name of the directory (generally not a path). Some servers will accept a wildcard.
      isLongListing - true if the listing is a long format listing
      Returns:
      String[]
      Throws:
      FTPException
      IOException
    • directoryList

      FTPFile[] directoryList() throws FTPException, IOException, ParseException
      List the current directory on the FTP server.
      Throws:
      ParseException
      FTPException
      IOException
    • directoryList

      FTPFile[] directoryList(String directoryName) throws FTPException, IOException, ParseException
      List a directory on the FTP server.
      Parameters:
      directoryName - name of the directory (generally not a path). Some servers will accept a wildcard.
      Throws:
      ParseException
      FTPException
      IOException
    • directoryList

      void directoryList(String directoryName, DirectoryListCallback lister) throws FTPException, IOException, ParseException
      List a directory on the FTP server.
      Parameters:
      directoryName - name of the directory (generally not a path)
      Throws:
      FTPException
      IOException
      ParseException
    • downloadByteArray

      byte[] downloadByteArray(String remoteFileName) throws FTPException, IOException
      Download a file from the FTP server into a byte array.
      Parameters:
      remoteFileName - name of the remote file to be downloaded
      Throws:
      FTPException
      IOException
    • downloadFile

      void downloadFile(String localFileName, String remoteFileName) throws FTPException, IOException
      Download a file from the FTP server .
      Parameters:
      localFileName - name (or full path) of the local file to be downloaded to
      remoteFileName - name of the remote file to be downloaded
      Throws:
      FTPException
      IOException
    • downloadFile

      void downloadFile(String localFileName, String remoteFileName, WriteMode writeMode) throws FTPException, IOException
      Download a file from the FTP server .
      Parameters:
      localFileName - name (or full path) of the local file to be downloaded to
      remoteFileName - name of the remote file to be downloaded
      writeMode - mode in which the file is written to the client machine
      Throws:
      FTPException
      IOException
    • downloadStream

      FileTransferInputStream downloadStream(String remoteFileName) throws FTPException, IOException
      Download a file from the FTP server as a stream. The close() method must be called on the stream once the stream has been read.
      Parameters:
      remoteFileName - name of the remote file to be downloaded
      Returns:
      InputStream
      Throws:
      FTPException
      IOException
    • uploadFile

      String uploadFile(String localFileName, String remoteFileName) throws FTPException, IOException
      Upload a file to the FTP server. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file.
      Parameters:
      localFileName - name (or full path) of the local file to be downloaded to
      remoteFileName - name of the remote file to be downloaded (or null to generate a unique name)
      Returns:
      name of remote file
      Throws:
      FTPException
      IOException
    • uploadFile

      String uploadFile(String localFileName, String remoteFileName, WriteMode writeMode) throws FTPException, IOException
      Upload a file to the FTP server. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file.
      Parameters:
      localFileName - name (or full path) of the local file to be downloaded to
      remoteFileName - name of the remote file to be downloaded (or null to generate a unique name)
      writeMode - mode to write to the remote file with
      Returns:
      name of remote file
      Throws:
      FTPException
      IOException
    • uploadStream

      FileTransferOutputStream uploadStream(String remoteFileName) throws FTPException, IOException
      Upload a file to the FTP server by writing to a stream. The close() method must be called on the stream once the stream has been read. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from
      Parameters:
      remoteFileName - name of the remote file to be uploaded
      Returns:
      FTPOutputStream
      Throws:
      FTPException
      IOException
    • uploadStream

      FileTransferOutputStream uploadStream(String remoteFileName, WriteMode writeMode) throws FTPException, IOException
      Upload a file to the FTP server by writing to a stream. The close() method *must* be called on the stream once the stream has been read. If a null is supplied as the remoteFileName, the STOU (store unique) FTP feature will be used (if available) and the FTP server will generate a unique name for the file. This name can be obtained afterwards from
      Parameters:
      remoteFileName - name of the remote file to be uploaded
      writeMode - mode for writing to the server (supporting use of append)
      Returns:
      FTPOutputStream
      Throws:
      FTPException
      IOException
    • getSize

      long getSize(String remoteFileName) throws FTPException, IOException
      Get the size of a remote file.
      Parameters:
      remoteFileName - name of remote file
      Returns:
      long
      Throws:
      FTPException
      IOException
    • getModifiedTime

      Date getModifiedTime(String remoteFileName) throws FTPException, IOException
      Get the modified-time of a remote file. May not be supported by all servers.
      Parameters:
      remoteFileName - name of remote file
      Returns:
      Date
      Throws:
      FTPException
      IOException
    • setModifiedTime

      void setModifiedTime(String remoteFileName, Date modifiedTime) throws FTPException, IOException
      Set the modified-time of a remote file. May not be supported by all servers.
      Parameters:
      remoteFileName - name of remote file
      modifiedTime - new modified time
      Throws:
      FTPException
      IOException
    • exists

      boolean exists(String remoteFileName) throws FTPException, IOException
      Determine if a remote file exists.
      Parameters:
      remoteFileName - name of remote file
      Throws:
      FTPException
      IOException
    • deleteFile

      void deleteFile(String remoteFileName) throws FTPException, IOException
      Deletes a remote file.
      Parameters:
      remoteFileName - name of remote file
      Throws:
      FTPException
      IOException
    • rename

      void rename(String renameFromName, String renameToName) throws FTPException, IOException
      Rename a remote file or directory.
      Parameters:
      renameFromName - original name
      renameToName - new name
      Throws:
      FTPException
      IOException
    • changeDirectory

      void changeDirectory(String directoryName) throws FTPException, IOException
      Change directory on the FTP server.
      Parameters:
      directoryName - name the remote directory to change into
      Throws:
      FTPException
      IOException
    • changeToParentDirectory

      void changeToParentDirectory() throws FTPException, IOException
      Change to parent directory on the FTP server.
      Throws:
      FTPException
      IOException
    • getRemoteDirectory

      String getRemoteDirectory() throws IOException, FTPException
      Get the current remote directory.
      Returns:
      current remote directory
      Throws:
      FTPException
      IOException
    • createDirectory

      void createDirectory(String directoryName) throws FTPException, IOException
      Create directory on the FTP server.
      Parameters:
      directoryName - name the remote directory to create
      Throws:
      FTPException
      IOException
    • deleteDirectory

      void deleteDirectory(String directoryName) throws FTPException, IOException
      Delete directory on the FTP server. The directory must be empty. Note that edtFTPj/PRO supports recursive directory deletions.
      Parameters:
      directoryName - name the remote directory to create
      Throws:
      FTPException
      IOException
    • disconnect

      void disconnect() throws FTPException, IOException
      Disconnect from the FTP server.
      Throws:
      FTPException
      IOException
    • disconnect

      void disconnect(boolean immediate) throws FTPException, IOException
      Disconnect from the FTP server.
      Throws:
      FTPException
      IOException