Class FtpFileObject
- java.lang.Object
-
- org.apache.commons.vfs2.provider.AbstractFileObject<FtpFileSystem>
-
- org.apache.commons.vfs2.provider.ftp.FtpFileObject
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.lang.Comparable<FileObject>,java.lang.Iterable<FileObject>,FileObject
public class FtpFileObject extends AbstractFileObject<FtpFileSystem>
An FTP file.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedFtpFileObject(AbstractFileName name, FtpFileSystem fileSystem, FileName rootName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voiddoAttach()Attaches this file object to its file resource.protected voiddoCreateFolder()Creates this file as a folder.protected voiddoDelete()Deletes the file.protected voiddoDetach()Detaches this file object from its file resource.protected longdoGetContentSize()Returns the size of the file content (in bytes).protected java.io.InputStreamdoGetInputStream()Creates an input stream to read the file content from.protected longdoGetLastModifiedTime()get the last modified time on an ftp fileprotected java.io.OutputStreamdoGetOutputStream(boolean bAppend)Creates an output stream to write the file content to.protected RandomAccessContentdoGetRandomAccessContent(RandomAccessMode mode)Creates access to the file for random i/o.protected FileTypedoGetType()Determines the type of the file, returns null if the file does not exist.protected java.lang.String[]doListChildren()Lists the children of the file.protected FileObject[]doListChildrenResolved()Lists the children of this file.protected voiddoRename(FileObject newFile)Renames the fileFileObject[]getChildren()Returns the file's list of children.protected voidonChange()Called when the type or content of this file changes.protected voidonChildrenChanged(FileName child, FileType newType)Called when the children of this file change.voidrefresh()This will prepare the fileObject to get resynchronized with the underlying filesystem if required.-
Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObject
canRenameTo, childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doCreateFileContent, doGetAttributes, doGetCertificates, doIsExecutable, doIsHidden, doIsReadable, doIsSameFile, doIsWriteable, doRemoveAttribute, doSetAttribute, doSetExecutable, doSetLastModifiedTime, doSetReadable, doSetWritable, endOutput, exists, finalize, findFiles, findFiles, getAbstractFileSystem, getChild, getContent, getFileContentInfoFactory, getFileOperations, getFileSystem, getInputStream, getName, getOutputStream, getOutputStream, getParent, getPublicURIString, getRandomAccessContent, getType, getURL, handleChanged, handleCreate, handleDelete, holdObject, injectType, isAttached, isContentOpen, isExecutable, isFile, isFolder, isHidden, isReadable, isSameFile, isWriteable, iterator, listFiles, moveTo, notifyAllStreamsClosed, resolveFile, resolveFile, setExecutable, setReadable, setWritable, toString
-
-
-
-
Constructor Detail
-
FtpFileObject
protected FtpFileObject(AbstractFileName name, FtpFileSystem fileSystem, FileName rootName) throws FileSystemException
- Throws:
FileSystemException
-
-
Method Detail
-
doAttach
protected void doAttach() throws java.io.IOException
Attaches this file object to its file resource.- Overrides:
doAttachin classAbstractFileObject<FtpFileSystem>- Throws:
java.io.IOException
-
refresh
public void refresh() throws FileSystemException
Description copied from class:AbstractFileObjectThis will prepare the fileObject to get resynchronized with the underlying filesystem if required.- Specified by:
refreshin interfaceFileObject- Overrides:
refreshin classAbstractFileObject<FtpFileSystem>- Throws:
FileSystemException- if an error occurs.
-
doDetach
protected void doDetach()
Detaches this file object from its file resource.- Overrides:
doDetachin classAbstractFileObject<FtpFileSystem>
-
onChildrenChanged
protected void onChildrenChanged(FileName child, FileType newType)
Called when the children of this file change.- Overrides:
onChildrenChangedin classAbstractFileObject<FtpFileSystem>- Parameters:
child- The name of the child that changed.newType- The type of the file.
-
onChange
protected void onChange() throws java.io.IOException
Called when the type or content of this file changes.- Overrides:
onChangein classAbstractFileObject<FtpFileSystem>- Throws:
java.io.IOException
-
doGetType
protected FileType doGetType() throws java.lang.Exception
Determines the type of the file, returns null if the file does not exist.- Specified by:
doGetTypein classAbstractFileObject<FtpFileSystem>- Returns:
- the type of the file.
- Throws:
java.lang.Exception- if an error occurs.
-
doListChildrenResolved
protected FileObject[] doListChildrenResolved() throws java.lang.Exception
Description copied from class:AbstractFileObjectLists the children of this file.Is only called if
AbstractFileObject.doGetType()returnsFileType.FOLDER.The return value of this method is cached, so the implementation can be expensive.
Other thandoListChildrenyou could return FileObject's to e.g. reinitialize the type of the file.(Introduced for Webdav: "permission denied on resource" during getType())
- Overrides:
doListChildrenResolvedin classAbstractFileObject<FtpFileSystem>- Returns:
- The children of this FileObject.
- Throws:
java.lang.Exception- if an error occurs.
-
getChildren
public FileObject[] getChildren() throws FileSystemException
Returns the file's list of children.- Specified by:
getChildrenin interfaceFileObject- Overrides:
getChildrenin classAbstractFileObject<FtpFileSystem>- Returns:
- The list of children
- Throws:
FileSystemException- If there was a problem listing children- Since:
- 2.0
- See Also:
AbstractFileObject.getChildren()
-
doListChildren
protected java.lang.String[] doListChildren() throws java.lang.Exception
Lists the children of the file.- Specified by:
doListChildrenin classAbstractFileObject<FtpFileSystem>- 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:
java.lang.Exception- if an error occurs.
-
doDelete
protected void doDelete() throws java.lang.Exception
Deletes the file.- Overrides:
doDeletein classAbstractFileObject<FtpFileSystem>- Throws:
java.lang.Exception- if an error occurs.
-
doRename
protected void doRename(FileObject newFile) throws java.lang.Exception
Renames the file- Overrides:
doRenamein classAbstractFileObject<FtpFileSystem>- Parameters:
newFile- A FileObject with the new file name.- Throws:
java.lang.Exception- if an error occurs.
-
doCreateFolder
protected void doCreateFolder() throws java.lang.Exception
Creates this file as a folder.- Overrides:
doCreateFolderin classAbstractFileObject<FtpFileSystem>- Throws:
java.lang.Exception- if an error occurs.
-
doGetContentSize
protected long doGetContentSize() throws java.lang.Exception
Returns the size of the file content (in bytes).- Specified by:
doGetContentSizein classAbstractFileObject<FtpFileSystem>- Returns:
- The size of the file in bytes.
- Throws:
java.lang.Exception- if an error occurs.
-
doGetLastModifiedTime
protected long doGetLastModifiedTime() throws java.lang.Exception
get the last modified time on an ftp file- Overrides:
doGetLastModifiedTimein classAbstractFileObject<FtpFileSystem>- Returns:
- The last modification time.
- Throws:
java.lang.Exception- if an error occurs.- See Also:
AbstractFileObject.doGetLastModifiedTime()
-
doGetInputStream
protected java.io.InputStream doGetInputStream() throws java.lang.Exception
Creates an input stream to read the file content from.- Specified by:
doGetInputStreamin classAbstractFileObject<FtpFileSystem>- Returns:
- An InputStream to read the file content.
- Throws:
java.lang.Exception- if an error occurs.
-
doGetRandomAccessContent
protected RandomAccessContent doGetRandomAccessContent(RandomAccessMode mode) throws java.lang.Exception
Description 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 classAbstractFileObject<FtpFileSystem>- Parameters:
mode- The mode to access the file.- Returns:
- The RandomAccessContext.
- Throws:
java.lang.Exception- if an error occurs.
-
doGetOutputStream
protected java.io.OutputStream doGetOutputStream(boolean bAppend) throws java.lang.Exception
Creates an output stream to write the file content to.- Overrides:
doGetOutputStreamin classAbstractFileObject<FtpFileSystem>- 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:
java.lang.Exception- if an error occurs.
-
-