Class SftpFileObject
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Comparable<FileObject>,- Iterable<FileObject>,- FileObject
- 
Field SummaryFields inherited from class org.apache.commons.vfs2.provider.AbstractFileObjectDEFAULT_BUFFER_SIZEFields inherited from interface org.apache.commons.vfs2.FileObjectEMPTY_ARRAY
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedSftpFileObject(AbstractFileName fileName, SftpFileSystem fileSystem) Constructs a new instance.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidCreates this file as a folder.protected voiddoDelete()Deletes the file.protected voiddoDetach()Detaches this file object from its file resource.protected longReturns the size of the file content (in bytes).protected InputStreamdoGetInputStream(int bufferSize) Creates an input stream to read the file content from.protected longReturns the last modified time of this file.protected OutputStreamdoGetOutputStream(boolean bAppend) Creates an output stream to write the file content to.protected RandomAccessContentCreates access to the file for random i/o.protected FileTypeDetermines the type of this file, returns null if the file does not exist.protected booleanDetermines if this file is executable.protected booleanDetermines if this file can be read.protected booleanDetermines if this file can be written to.protected String[]Lists the children of this file.protected FileObject[]Lists the children of this file.protected voiddoRename(FileObject newFile) Renames the file.protected booleandoSetExecutable(boolean executable, boolean ownerOnly) Make the file executable.protected booleandoSetLastModifiedTime(long modtime) Sets the last modified time of this file.protected booleandoSetReadable(boolean readable, boolean ownerOnly) Make the file or folder readable.protected booleandoSetWritable(boolean writable, boolean ownerOnly) Make the file or folder writable.protected PosixPermissionsgetPermissions(boolean checkIds) Returns the POSIX type permissions of the file.protected voidonChange()Called when the type or content of this file changes.Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObjectcanRenameTo, childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doAttach, doCreateFileContent, doGetAttributes, doGetCertificates, doGetInputStream, doIsHidden, doIsSameFile, doIsSymbolicLink, doRemoveAttribute, doSetAttribute, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getChildren, getContent, getFileContentInfoFactory, getFileOperations, getFileSystem, getInputStream, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, isSymbolicLink, isWriteable, iterator, listFiles, moveTo, notifyAllStreamsClosed, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toStringMethods inherited from class java.lang.Objectclone, equals, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.commons.vfs2.FileObjectgetPath, getURIMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
SftpFileObjectprotected SftpFileObject(AbstractFileName fileName, SftpFileSystem fileSystem) throws FileSystemException Constructs a new instance.- Parameters:
- fileName- the file name.
- fileSystem- the file system.
- Throws:
- FileSystemException- if a file system error occurs.
 
 
- 
- 
Method Details- 
doCreateFolderCreates this file as a folder.- Overrides:
- doCreateFolderin class- AbstractFileObject<SftpFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doDeleteDeletes the file.- Overrides:
- doDeletein class- AbstractFileObject<SftpFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doDetachDescription copied from class:AbstractFileObjectDetaches this file object from its file resource.Called when this file is closed. Note that the file object may be reused later, so should be able to be reattached. This implementation does nothing. - Overrides:
- doDetachin class- AbstractFileObject<SftpFileSystem>
- Throws:
- Exception- if an error occurs.
- Since:
- 2.0
 
- 
doGetContentSizeReturns the size of the file content (in bytes).- Specified by:
- doGetContentSizein class- AbstractFileObject<SftpFileSystem>
- Returns:
- The size of the file in bytes.
- Throws:
- Exception- if an error occurs.
 
- 
doGetInputStreamCreates an input stream to read the file content from.- Overrides:
- doGetInputStreamin class- AbstractFileObject<SftpFileSystem>
- Parameters:
- bufferSize- Buffer size hint.
- Returns:
- An InputStream to read the file content.
- Throws:
- Exception- if an error occurs.
 
- 
doGetLastModifiedTimeDescription copied from class:AbstractFileObjectReturns the last modified time of this file. Is only called ifAbstractFileObject.doGetType()does not returnThis implementation throws an exception. - Overrides:
- doGetLastModifiedTimein class- AbstractFileObject<SftpFileSystem>
- Returns:
- The last modification time.
- Throws:
- Exception- if an error occurs.
 
- 
doGetOutputStreamCreates an output stream to write the file content to.- Overrides:
- doGetOutputStreamin class- AbstractFileObject<SftpFileSystem>
- Parameters:
- bAppend- true if the file should be appended to, false if it should be overwritten.
- Returns:
- An OutputStream to write to the file.
- Throws:
- Exception- if an error occurs.
 
- 
doGetRandomAccessContentDescription copied from class:AbstractFileObjectCreates access to the file for random i/o. Is only called ifAbstractFileObject.doGetType()returnsFileType.FILE.It is guaranteed that there are no open output streams for this file when this method is called. - Overrides:
- doGetRandomAccessContentin class- AbstractFileObject<SftpFileSystem>
- Parameters:
- mode- The mode to access the file.
- Returns:
- The RandomAccessContext.
- Throws:
- Exception- if an error occurs.
 
- 
doGetTypeDetermines the type of this file, returns null if the file does not exist.- Specified by:
- doGetTypein class- AbstractFileObject<SftpFileSystem>
- Returns:
- the type of the file.
- Throws:
- Exception- if an error occurs.
 
- 
doIsExecutableDescription copied from class:AbstractFileObjectDetermines if this file is executable. Is only called ifAbstractFileObject.doGetType()does not returnFileType.IMAGINARY.This implementation always returns false. - Overrides:
- doIsExecutablein class- AbstractFileObject<SftpFileSystem>
- Returns:
- true if the file is executable, false otherwise.
- Throws:
- Exception- if an error occurs.
 
- 
doIsReadableDescription copied from class:AbstractFileObjectDetermines if this file can be read. Is only called ifAbstractFileObject.doGetType()does not returnFileType.IMAGINARY.This implementation always returns true. - Overrides:
- doIsReadablein class- AbstractFileObject<SftpFileSystem>
- Returns:
- true if the file is readable, false otherwise.
- Throws:
- Exception- if an error occurs.
 
- 
doIsWriteableDescription copied from class:AbstractFileObjectDetermines if this file can be written to. Is only called ifAbstractFileObject.doGetType()does not returnFileType.IMAGINARY.This implementation always returns true. - Overrides:
- doIsWriteablein class- AbstractFileObject<SftpFileSystem>
- Returns:
- true if the file is writable.
- Throws:
- Exception- if an error occurs.
 
- 
doListChildrenLists the children of this file.- Specified by:
- doListChildrenin class- AbstractFileObject<SftpFileSystem>
- Returns:
- a possible empty String array if the file is a directory or null or an exception if the file is not a directory or can't be read.
- Throws:
- Exception- if an error occurs.
 
- 
doListChildrenResolvedLists the children of this file.- Overrides:
- doListChildrenResolvedin class- AbstractFileObject<SftpFileSystem>
- Returns:
- The children of this FileObject.
- Throws:
- Exception- if an error occurs.
 
- 
doRenameRenames the file.- Overrides:
- doRenamein class- AbstractFileObject<SftpFileSystem>
- Parameters:
- newFile- A FileObject with the new file name.
- Throws:
- Exception- if an error occurs.
 
- 
doSetExecutableDescription copied from class:AbstractFileObjectMake the file executable.Only called if AbstractFileObject.doGetType()does not returnFileType.IMAGINARY.This implementation returns false. - Overrides:
- doSetExecutablein class- AbstractFileObject<SftpFileSystem>
- Parameters:
- executable- True to allow access, false to disallow.
- ownerOnly- If- true, the permission applies only to the owner; otherwise, it applies to everybody.
- Returns:
- true if the operation succeeded.
- Throws:
- Exception- Any Exception thrown is wrapped in FileSystemException.
- See Also:
 
- 
doSetLastModifiedTimeSets the last modified time of this file. Is only called ifdoGetType()does not returnFileType.IMAGINARY.- Overrides:
- doSetLastModifiedTimein class- AbstractFileObject<SftpFileSystem>
- Parameters:
- modtime- is modification time in milliseconds. SFTP protocol can send times with nanosecond precision but at the moment jsch send them with second precision.
- Returns:
- true if the time was set.
- Throws:
- Exception- Any Exception thrown is wrapped in FileSystemException.
 
- 
doSetReadableDescription copied from class:AbstractFileObjectMake the file or folder readable.Only called if AbstractFileObject.doGetType()does not returnFileType.IMAGINARY.This implementation returns false. - Overrides:
- doSetReadablein class- AbstractFileObject<SftpFileSystem>
- Parameters:
- readable- True to allow access, false to disallow
- ownerOnly- If- true, the permission applies only to the owner; otherwise, it applies to everybody.
- Returns:
- true if the operation succeeded
- Throws:
- Exception- Any Exception thrown is wrapped in FileSystemException.
- See Also:
 
- 
doSetWritableDescription copied from class:AbstractFileObjectMake the file or folder writable.Only called if AbstractFileObject.doGetType()does not returnFileType.IMAGINARY.- Overrides:
- doSetWritablein class- AbstractFileObject<SftpFileSystem>
- Parameters:
- writable- True to allow access, false to disallow
- ownerOnly- If- true, the permission applies only to the owner; otherwise, it applies to everybody.
- Returns:
- true if the operation succeeded
- Throws:
- Exception- Any Exception thrown is wrapped in FileSystemException.
- See Also:
 
- 
getPermissionsReturns the POSIX type permissions of the file.- Parameters:
- checkIds-- trueif user and group ID should be checked (needed for some access rights checks)
- Returns:
- A PosixPermission object
- Throws:
- Exception- If an error occurs
- Since:
- 2.1
 
- 
onChangeCalled when the type or content of this file changes.- Overrides:
- onChangein class- AbstractFileObject<SftpFileSystem>
- Throws:
- Exception- if an error occurs.
 
 
-