Class LocalFile
java.lang.Object
org.apache.commons.vfs2.provider.AbstractFileObject<LocalFileSystem>
org.apache.commons.vfs2.provider.local.LocalFile
- All Implemented Interfaces:
- Closeable,- AutoCloseable,- Comparable<FileObject>,- Iterable<FileObject>,- FileObject
A file object implementation which uses direct file access.
- 
Field SummaryFields inherited from class org.apache.commons.vfs2.provider.AbstractFileObjectDEFAULT_BUFFER_SIZEFields inherited from interface org.apache.commons.vfs2.FileObjectEMPTY_ARRAY
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedLocalFile(LocalFileSystem fileSystem, String rootFile, AbstractFileName name) Creates a non-root file.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voiddoAttach()Attaches this file object to its file resource.protected voidCreates this folder.protected voiddoDelete()Deletes this file, and all children.protected longReturns the size of the file content (in bytes).protected InputStreamdoGetInputStream(int bufferSize) Creates an input stream to read the file contents.protected longGets the last modified time of this file.protected OutputStreamdoGetOutputStream(boolean append) Creates an output stream to write the file content to.protected RandomAccessContentCreates access to the file for random i/o.protected FileTypeReturns the file's type.protected booleanDetermines if this file is hidden.protected booleanDetermines if this file is hidden.protected booleanDetermines if this file can be read.protected booleandoIsSameFile(FileObject destFile) Checks if this fileObject is the same file asdestFilejust with a different name.protected booleanDetermines if this file is a symbolic link.protected booleanDetermines if this file can be written to.protected String[]Returns the children of the file.protected voiddoRename(FileObject newFile) rename this fileprotected 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 FileGets the local file that this file object represents.toString()Returns the URI of the file.Methods inherited from class org.apache.commons.vfs2.provider.AbstractFileObjectcanRenameTo, childrenChanged, close, compareTo, copyFrom, createFile, createFolder, delete, delete, deleteAll, doCreateFileContent, doDetach, doGetAttributes, doGetCertificates, doGetInputStream, doListChildrenResolved, 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, onChange, onChildrenChanged, refresh, resolveFile, resolveFile, setExecutable, setReadable, setWritableMethods 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- 
LocalFileCreates a non-root file.- Parameters:
- fileSystem- the file system this file belongs to.
- rootFile- the root file for the file system.
- name- the file name on this file system.
 
 
- 
- 
Method Details- 
doAttachAttaches this file object to its file resource.- Overrides:
- doAttachin class- AbstractFileObject<LocalFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doCreateFolderCreates this folder.- Overrides:
- doCreateFolderin class- AbstractFileObject<LocalFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doDeleteDeletes this file, and all children.- Overrides:
- doDeletein class- AbstractFileObject<LocalFileSystem>
- Throws:
- Exception- if an error occurs.
 
- 
doGetContentSizeReturns the size of the file content (in bytes).- Specified by:
- doGetContentSizein class- AbstractFileObject<LocalFileSystem>
- Returns:
- The size of the file in bytes.
- Throws:
- Exception- if an error occurs.
 
- 
doGetInputStreamCreates an input stream to read the file contents.- Overrides:
- doGetInputStreamin class- AbstractFileObject<LocalFileSystem>
- Parameters:
- bufferSize- Buffer size hint.
- Returns:
- An InputStream to read the file content.
- Throws:
- Exception- if an error occurs.
 
- 
doGetLastModifiedTimeGets the last modified time of this file.- Overrides:
- doGetLastModifiedTimein class- AbstractFileObject<LocalFileSystem>
- Returns:
- The last modification time.
- Throws:
- FileSystemException
 
- 
doGetOutputStreamCreates an output stream to write the file content to.- Overrides:
- doGetOutputStreamin class- AbstractFileObject<LocalFileSystem>
- Parameters:
- append- true if the file should be appended to, false if it should be overwritten.
- Returns:
- An OutputStream to write to the file.
- Throws:
- IOException
 
- 
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<LocalFileSystem>
- Parameters:
- mode- The mode to access the file.
- Returns:
- The RandomAccessContext.
- Throws:
- Exception- if an error occurs.
 
- 
doGetTypeReturns the file's type.- Specified by:
- doGetTypein class- AbstractFileObject<LocalFileSystem>
- Returns:
- the type of the file.
 
- 
doIsExecutableDetermines if this file is hidden.- Overrides:
- doIsExecutablein class- AbstractFileObject<LocalFileSystem>
- Returns:
- true if the file is executable, false otherwise.
 
- 
doIsHiddenDetermines if this file is hidden.- Overrides:
- doIsHiddenin class- AbstractFileObject<LocalFileSystem>
- Returns:
- true if the file is hidden, false otherwise.
 
- 
doIsReadableDetermines if this file can be read.- Overrides:
- doIsReadablein class- AbstractFileObject<LocalFileSystem>
- Returns:
- true if the file is readable, false otherwise.
- Throws:
- FileSystemException
 
- 
doIsSameFileDescription copied from class:AbstractFileObjectChecks if this fileObject is the same file asdestFilejust with a different name. E.g. for case-insensitive file systems like Windows.- Overrides:
- doIsSameFilein class- AbstractFileObject<LocalFileSystem>
- Parameters:
- destFile- The file to compare to.
- Returns:
- true if the FileObjects are the same.
- Throws:
- FileSystemException- if an error occurs.
 
- 
doIsSymbolicLinkDetermines if this file is a symbolic link.- Overrides:
- doIsSymbolicLinkin class- AbstractFileObject<LocalFileSystem>
- Returns:
- true if the file is readable, false otherwise.
- Throws:
- FileSystemException
- Since:
- 2.4
 
- 
doIsWriteableDetermines if this file can be written to.- Overrides:
- doIsWriteablein class- AbstractFileObject<LocalFileSystem>
- Returns:
- true if the file is writable.
- Throws:
- FileSystemException
 
- 
doListChildrenReturns the children of the file.- Specified by:
- doListChildrenin class- AbstractFileObject<LocalFileSystem>
- 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.
 
- 
doRenamerename this file- Overrides:
- doRenamein class- AbstractFileObject<LocalFileSystem>
- 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<LocalFileSystem>
- 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.- Overrides:
- doSetLastModifiedTimein class- AbstractFileObject<LocalFileSystem>
- Parameters:
- modtime- The last modification time.
- Returns:
- true if the time was set.
- Throws:
- FileSystemException
- Since:
- 2.0
 
- 
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<LocalFileSystem>
- 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<LocalFileSystem>
- 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:
 
- 
getLocalFileGets the local file that this file object represents.- Returns:
- the local file that this file object represents.
 
- 
toStringReturns the URI of the file.- Overrides:
- toStringin class- AbstractFileObject<LocalFileSystem>
- Returns:
- The URI of the file.
 
 
-