Package com.sshtools.client.sftp
Class SftpFile
java.lang.Object
com.sshtools.client.sftp.SftpFile
Represents an SFTP file object.
-
Method Summary
Modifier and TypeMethodDescriptioncom.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 thisSftpFile
.boolean
canRead()
Deprecated, for removal: This API element is subject to removal in a future version.boolean
canWrite()
Deprecated, for removal: This API element is subject to removal in a future version.void
delete()
Delete this file/directory from the remote server.boolean
Get the absolute pathcom.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.getProperty
(String key) 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
hashCode()
boolean
isBlock()
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
isFifo()
Deprecated, for removal: This API element is subject to removal in a future version.boolean
isFile()
Deprecated, for removal: This API element is subject to removal in a future version.boolean
isLink()
Determine whether the file object is a symbolic link.boolean
isSocket()
Deprecated, for removal: This API element is subject to removal in a future version.refresh()
Refresh theSftpFileAttributes
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.toString()
-
Method Details
-
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, callrefresh()
to obtain a newSftpFile
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 thisSftpFile
.- 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.SshExceptionRefresh theSftpFileAttributes
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.SftpStatusExceptionGet 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
-
hashCode
public int hashCode() -
equals
-
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.SshExceptionDelete 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.SshExceptionDeprecated, 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.SshExceptionDeprecated, 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
Get the SFTP subsystem channel that created this file object.- Returns:
- SftpSubsystemChannel
-
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.SftpStatusExceptionDeprecated, 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
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.SshExceptionDeprecated, 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 thenfalse
will be returned. Usecom.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 errorcom.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.SshExceptionDeprecated, 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 errorcom.sshtools.common.sftp.SftpStatusException
- on SFTP error
-
isLink
public boolean isLink() throws com.sshtools.common.sftp.SftpStatusException, com.sshtools.common.ssh.SshExceptionDetermine whether the file object is a symbolic link.- Returns:
- is link
- Throws:
com.sshtools.common.ssh.SshException
- on SSH errorcom.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.SshExceptionDeprecated, 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 errorcom.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.SshExceptionDeprecated, 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 errorcom.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.SshExceptionDeprecated, 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 errorcom.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.SshExceptionDeprecated, 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 errorcom.sshtools.common.sftp.SftpStatusException
- on SFTP error
-
setProperty
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
- keyvalue
- vlaue
-
getProperty
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
-