Interface FtpChannel

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static interface  FtpChannel.DirEntry
      Simplified remote directory entry.
      static class  FtpChannel.FtpException
      An Exception for reporting SFTP errors.
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void cd​(java.lang.String path)
      Changes the current remote directory.
      void connect​(int timeout, java.util.concurrent.TimeUnit unit)
      Connects the FtpChannel to the remote end.
      default void delete​(java.lang.String path)
      Deletes a file on the remote file system.
      void disconnect()
      Disconnects and FtpChannel.
      java.io.InputStream get​(java.lang.String path)
      Obtain an InputStream to read the contents of a remote file.
      boolean isConnected()  
      java.util.Collection<FtpChannel.DirEntry> ls​(java.lang.String path)
      Lists contents of a remote directory
      void mkdir​(java.lang.String path)
      Creates a directory on the remote file system.
      java.io.OutputStream put​(java.lang.String path)
      Obtain an OutputStream to write to a remote file.
      java.lang.String pwd()  
      void rename​(java.lang.String from, java.lang.String to)
      Renames a file on the remote file system.
      void rm​(java.lang.String path)
      Deletes a file on the remote file system.
      void rmdir​(java.lang.String path)
      Deletes a directory on the remote file system.
    • Method Detail

      • connect

        void connect​(int timeout,
                     java.util.concurrent.TimeUnit unit)
              throws java.io.IOException
        Connects the FtpChannel to the remote end.
        Parameters:
        timeout - for establishing the FTP connection
        unit - of the timeout
        Throws:
        java.io.IOException
      • disconnect

        void disconnect()
        Disconnects and FtpChannel.
      • isConnected

        boolean isConnected()
        Returns:
        whether the FtpChannel is connected
      • cd

        void cd​(java.lang.String path)
         throws java.io.IOException
        Changes the current remote directory.
        Parameters:
        path - target directory
        Throws:
        java.io.IOException - if the operation could not be performed remotely
      • pwd

        java.lang.String pwd()
                      throws java.io.IOException
        Returns:
        the current remote directory path
        Throws:
        java.io.IOException
      • ls

        java.util.Collection<FtpChannel.DirEntry> ls​(java.lang.String path)
                                              throws java.io.IOException
        Lists contents of a remote directory
        Parameters:
        path - of the directory to list
        Returns:
        the directory entries
        Throws:
        java.io.IOException
      • rmdir

        void rmdir​(java.lang.String path)
            throws java.io.IOException
        Deletes a directory on the remote file system. The directory must be empty.
        Parameters:
        path - to delete
        Throws:
        java.io.IOException
      • mkdir

        void mkdir​(java.lang.String path)
            throws java.io.IOException
        Creates a directory on the remote file system.
        Parameters:
        path - to create
        Throws:
        java.io.IOException
      • get

        java.io.InputStream get​(java.lang.String path)
                         throws java.io.IOException
        Obtain an InputStream to read the contents of a remote file.
        Parameters:
        path - of the file to read
        Returns:
        the stream to read from
        Throws:
        java.io.IOException
      • put

        java.io.OutputStream put​(java.lang.String path)
                          throws java.io.IOException
        Obtain an OutputStream to write to a remote file. If the file exists already, it will be overwritten.
        Parameters:
        path - of the file to read
        Returns:
        the stream to read from
        Throws:
        java.io.IOException
      • rm

        void rm​(java.lang.String path)
         throws java.io.IOException
        Deletes a file on the remote file system.
        Parameters:
        path - to delete
        Throws:
        java.io.IOException - if the file does not exist or could otherwise not be deleted
      • delete

        default void delete​(java.lang.String path)
                     throws java.io.IOException
        Deletes a file on the remote file system. If the file does not exist, no exception is thrown.
        Parameters:
        path - to delete
        Throws:
        java.io.IOException - if the file exist but could not be deleted
      • rename

        void rename​(java.lang.String from,
                    java.lang.String to)
             throws java.io.IOException
        Renames a file on the remote file system. If to exists, it is replaced by from. (POSIX rename() semantics)
        Parameters:
        from - original name of the file
        to - new name of the file
        Throws:
        java.io.IOException
        See Also:
        stdio.h: rename()