Package com.sshtools.client.sftp
Class SftpFile
java.lang.Object
com.sshtools.client.sftp.SftpFile
Represents an SFTP file object.
-
Method Summary
Modifier and TypeMethodDescriptionGet the attributes for this file as they were when this file object was obtained.attributes(SftpFileAttributes attributes) Set the given attributes on the remote file represented by thisSftpFile.booleancanRead()Deprecated, for removal: This API element is subject to removal in a future version.booleancanWrite()Deprecated, for removal: This API element is subject to removal in a future version.voiddelete()Delete this file/directory from the remote server.booleanGet the absolute pathDeprecated, 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.inthashCode()booleanisBlock()Deprecated, for removal: This API element is subject to removal in a future version.booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanisFifo()Deprecated, for removal: This API element is subject to removal in a future version.booleanisFile()Deprecated, for removal: This API element is subject to removal in a future version.booleanisLink()Determine whether the file object is a symbolic link.booleanisSocket()Deprecated, for removal: This API element is subject to removal in a future version.refresh()Refresh theSftpFileAttributesfrom the the remote file.voidsetProperty(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
Get the attributes for this file as they were when this file object was obtained. To get the latest attributes, callrefresh()to obtain a newSftpFileinstance.- Returns:
- attributes
-
attributes
Set the given attributes on the remote file represented by thisSftpFile.- Parameters:
attributes-- Returns:
- this
- Throws:
SftpStatusExceptionSshException
-
refresh
Refresh theSftpFileAttributesfrom the the remote file.- Returns:
- file new file instance
- Throws:
SftpStatusExceptionSshException
-
getParent
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:
SshExceptionSftpStatusException
-
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
Delete this file/directory from the remote server.- Throws:
SshExceptionSftpStatusException
-
canWrite
@Deprecated(since="3.1.0", forRemoval=true) public boolean canWrite() throws SftpStatusException, 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:
SftpStatusExceptionSshException
-
canRead
@Deprecated(since="3.1.0", forRemoval=true) public boolean canRead() throws SftpStatusException, 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:
SftpStatusExceptionSshException
-
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 SftpFileAttributes getAttributes() throws SshException, SftpStatusExceptionDeprecated, for removal: This API element is subject to removal in a future version.Get the files attributes.- Returns:
- SftpFileAttributes
- Throws:
SshExceptionSftpStatusException- See Also:
-
getAbsolutePath
Get the absolute path- Returns:
- String
-
isDirectory
@Deprecated(since="3.1.0", forRemoval=true) public boolean isDirectory() throws SftpStatusException, 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 thenfalsewill be returned. Usecom.sshtools.sftp.SftpClient#isDirectoryOrLinkedDirectory(SftpFile)instead if you wish to follow links.Deprecated, see
SftpFileAttributes.isDirectory().- Returns:
- is directory
- Throws:
SshException- on SSH errorSftpStatusException- on SFTP error
-
isFile
@Deprecated(since="3.1.0", forRemoval=true) public boolean isFile() throws SftpStatusException, 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:
SshException- on SSH errorSftpStatusException- on SFTP error
-
isLink
Determine whether the file object is a symbolic link.- Returns:
- is link
- Throws:
SshException- on SSH errorSftpStatusException- on SFTP error
-
isFifo
@Deprecated(since="3.1.0", forRemoval=true) public boolean isFifo() throws SftpStatusException, 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:
SshException- on SSH errorSftpStatusException- on SFTP error
-
isBlock
@Deprecated(since="3.1.0", forRemoval=true) public boolean isBlock() throws SftpStatusException, 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:
SshException- on SSH errorSftpStatusException- on SFTP error
-
isCharacter
@Deprecated(since="3.1.0", forRemoval=true) public boolean isCharacter() throws SftpStatusException, 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:
SshException- on SSH errorSftpStatusException- on SFTP error
-
isSocket
@Deprecated(since="3.1.0", forRemoval=true) public boolean isSocket() throws SftpStatusException, 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:
SshException- on SSH errorSftpStatusException- 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
-