Class SftpFile

java.lang.Object
com.sshtools.client.sftp.SftpFile

public final class SftpFile extends Object
Represents an SFTP file object.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.sshtools.common.sftp.SftpFileAttributes
    Get the attributes for this file as they were when this file object was obtained.
    attributes(com.sshtools.common.sftp.SftpFileAttributes attributes)
    Set the given attributes on the remote file represented by this SftpFile.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    void
    Delete this file/directory from the remote server.
    boolean
     
    Get the absolute path
    com.sshtools.common.sftp.SftpFileAttributes
    Deprecated, for removal: This API element is subject to removal in a future version. 
    Get the filename.
    The longname supplied by the server.
    Get the parent of the current file.
    Deprecated, for removal: This API element is subject to removal in a future version. 
    Get the SFTP subsystem channel that created this file object.
    handle(byte[] handle)
    Create a new handle for this file given the handle data.
    int
     
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    boolean
    Determine whether the file object is a symbolic link.
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
    Refresh the SftpFileAttributes from the the remote file.
    void
    setProperty(String key, Object value)
    Deprecated, for removal: This API element is subject to removal in a future version. 
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Method Details

    • handle

      public SftpHandle handle(byte[] handle)
      Create a new handle for this file given the handle data.
      Parameters:
      handle -
    • attributes

      public com.sshtools.common.sftp.SftpFileAttributes attributes()
      Get the attributes for this file as they were when this file object was obtained. To get the latest attributes, call refresh() to obtain a new SftpFile instance.
      Returns:
      attributes
    • attributes

      public SftpFile attributes(com.sshtools.common.sftp.SftpFileAttributes attributes) throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Set the given attributes on the remote file represented by this SftpFile.
      Parameters:
      attributes -
      Returns:
      this
      Throws:
      com.sshtools.common.sftp.SftpStatusException
      com.sshtools.common.ssh.SshException
    • refresh

      public SftpFile refresh() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Refresh the SftpFileAttributes from the the remote file.
      Returns:
      file new file instance
      Throws:
      com.sshtools.common.sftp.SftpStatusException
      com.sshtools.common.ssh.SshException
    • getParent

      public SftpFile getParent() throws com.sshtools.common.ssh.SshException, com.sshtools.common.sftp.SftpStatusException
      Get the parent of the current file. This method determines the correct path of the parent file; if no parent exists (i.e. the current file is the root of the filesystem) then this method returns a null value.
      Returns:
      SftpFile
      Throws:
      com.sshtools.common.ssh.SshException
      com.sshtools.common.sftp.SftpStatusException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getLongname

      public String getLongname()
      The longname supplied by the server. Note this will not be present if SFTP version is > 3.
      Returns:
    • delete

      public void delete() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Delete this file/directory from the remote server.
      Throws:
      com.sshtools.common.ssh.SshException
      com.sshtools.common.sftp.SftpStatusException
    • canWrite

      @Deprecated(since="3.1.0", forRemoval=true) public boolean canWrite() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the user has write access to the file. This checks the S_IWUSR flag is set in permissions.
      Returns:
      boolean
      Throws:
      com.sshtools.common.sftp.SftpStatusException
      com.sshtools.common.ssh.SshException
    • canRead

      @Deprecated(since="3.1.0", forRemoval=true) public boolean canRead() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the user has read access to the file. This checks the S_IRUSR flag is set in permissions.
      Returns:
      boolean
      Throws:
      com.sshtools.common.sftp.SftpStatusException
      com.sshtools.common.ssh.SshException
    • getSFTPChannel

      public SftpChannel getSFTPChannel()
      Get the SFTP subsystem channel that created this file object.
      Returns:
      SftpSubsystemChannel
    • getFilename

      public String getFilename()
      Get the filename.
      Returns:
      String
    • getAttributes

      @Deprecated(since="3.1.0", forRemoval=true) public com.sshtools.common.sftp.SftpFileAttributes getAttributes() throws com.sshtools.common.ssh.SshException, com.sshtools.common.sftp.SftpStatusException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the files attributes.
      Returns:
      SftpFileAttributes
      Throws:
      com.sshtools.common.ssh.SshException
      com.sshtools.common.sftp.SftpStatusException
      See Also:
    • getAbsolutePath

      public String getAbsolutePath()
      Get the absolute path
      Returns:
      String
    • isDirectory

      @Deprecated(since="3.1.0", forRemoval=true) public boolean isDirectory() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the file object is pointing to a directory. Note, if the file is a symbolic link pointing to a directory then false will be returned. Use com.sshtools.sftp.SftpClient#isDirectoryOrLinkedDirectory(SftpFile) instead if you wish to follow links.

      Deprecated, see SftpFileAttributes.isDirectory().

      Returns:
      is directory
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • isFile

      @Deprecated(since="3.1.0", forRemoval=true) public boolean isFile() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the file object is pointing to a file.

      Deprecated, see SftpFileAttributes.isDirectory().

      Returns:
      is file
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • isLink

      public boolean isLink() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Determine whether the file object is a symbolic link.
      Returns:
      is link
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • isFifo

      @Deprecated(since="3.1.0", forRemoval=true) public boolean isFifo() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the file is pointing to a pipe.
      Returns:
      is fifo
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • isBlock

      @Deprecated(since="3.1.0", forRemoval=true) public boolean isBlock() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the file is pointing to a block special file.
      Returns:
      is block special file
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • isCharacter

      @Deprecated(since="3.1.0", forRemoval=true) public boolean isCharacter() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the file is pointing to a character mode device.
      Returns:
      is character mode device
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • isSocket

      @Deprecated(since="3.1.0", forRemoval=true) public boolean isSocket() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Determine whether the file is pointing to a socket.
      Returns:
      is socket file
      Throws:
      com.sshtools.common.ssh.SshException - on SSH error
      com.sshtools.common.sftp.SftpStatusException - on SFTP error
    • setProperty

      @Deprecated(since="3.1.0", forRemoval=true) public void setProperty(String key, Object value)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set an arbitrary property in this file object.

      Deprecated, no replacement.

      Parameters:
      key - key
      value - vlaue
    • getProperty

      @Deprecated(since="3.1.0", forRemoval=true) public Object getProperty(String key)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get an arbitrary property stored in this file object.

      Deprecated, no replacement.

      Parameters:
      key - key
      Returns:
      value