Class SshdSession.SshdFtpChannel

  • All Implemented Interfaces:
    FtpChannel
    Enclosing class:
    SshdSession

    private class SshdSession.SshdFtpChannel
    extends java.lang.Object
    implements FtpChannel
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String cwd
      Current working directory.
      private org.apache.sshd.client.subsystem.sftp.SftpClient ftp  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private SshdFtpChannel()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private java.lang.String absolute​(java.lang.String path)  
      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.
      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
      private <T> T map​(SshdSession.FtpOperation<T> op)  
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ftp

        private org.apache.sshd.client.subsystem.sftp.SftpClient ftp
      • cwd

        private java.lang.String cwd
        Current working directory.
    • Constructor Detail

      • SshdFtpChannel

        private SshdFtpChannel()
    • Method Detail

      • connect

        public void connect​(int timeout,
                            java.util.concurrent.TimeUnit unit)
                     throws java.io.IOException
        Description copied from interface: FtpChannel
        Connects the FtpChannel to the remote end.
        Specified by:
        connect in interface FtpChannel
        Parameters:
        timeout - for establishing the FTP connection
        unit - of the timeout
        Throws:
        java.io.IOException
      • absolute

        private java.lang.String absolute​(java.lang.String path)
      • cd

        public void cd​(java.lang.String path)
                throws java.io.IOException
        Description copied from interface: FtpChannel
        Changes the current remote directory.
        Specified by:
        cd in interface FtpChannel
        Parameters:
        path - target directory
        Throws:
        java.io.IOException - if the operation could not be performed remotely
      • pwd

        public java.lang.String pwd()
                             throws java.io.IOException
        Specified by:
        pwd in interface FtpChannel
        Returns:
        the current remote directory path
        Throws:
        java.io.IOException
      • ls

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

        public void rmdir​(java.lang.String path)
                   throws java.io.IOException
        Description copied from interface: FtpChannel
        Deletes a directory on the remote file system. The directory must be empty.
        Specified by:
        rmdir in interface FtpChannel
        Parameters:
        path - to delete
        Throws:
        java.io.IOException
      • mkdir

        public void mkdir​(java.lang.String path)
                   throws java.io.IOException
        Description copied from interface: FtpChannel
        Creates a directory on the remote file system.
        Specified by:
        mkdir in interface FtpChannel
        Parameters:
        path - to create
        Throws:
        java.io.IOException
      • get

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

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

        public void rm​(java.lang.String path)
                throws java.io.IOException
        Description copied from interface: FtpChannel
        Deletes a file on the remote file system.
        Specified by:
        rm in interface FtpChannel
        Parameters:
        path - to delete
        Throws:
        java.io.IOException - if the file does not exist or could otherwise not be deleted
      • rename

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