public class VFSFileSystem extends Object implements FileSystem
FileSystem
implementation.SEPARATOR, SEPARATOR_CHAR
Constructor and Description |
---|
VFSFileSystem()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the file system.
|
protected org.apache.commons.vfs2.FileSystemManager |
createFileSystemManager()
Creates a
FileSystemManager instance. |
protected org.apache.commons.vfs2.FileSystemOptions |
createFileSystemOptions()
Builds and returns
FileSystemOptions instance which is used when resolving the baseFolder
during the initialization. |
void |
createFolder(String folderPath)
Creates the folder named by this path, including any necessary but
nonexistent parent folders.
|
void |
deleteFile(String filePath)
Deletes the file denoted by this path.
|
void |
deleteFolder(String folderPath)
Deletes the folder denoted by this path.
|
boolean |
equals(Object obj) |
boolean |
exists(String path)
Tests whether the file system entry denoted by this path exists.
|
String |
getConfig()
Return path of configuration properties.
|
org.apache.commons.vfs2.FileSystemManager |
getFileSystemManager()
Returns the VFS
FileSystemManager instance used in this VFS file system. |
String |
getFileSystemManagerClassName()
Returns the class name of the VFS
FileSystemManager instance used in this VFS file system. |
org.apache.commons.vfs2.FileSystemOptions |
getFileSystemOptions()
Returns
FileSystemOptions instance used when resolving the baseFolder . |
protected Properties |
getFileSystemOptionsProperties()
Returns properties used when building a
FileSystemOptions instance by the properties
during the initialization. |
InputStream |
getInputStream(String filePath)
Returns an input stream of the contents of the file denoted by this path.
|
OutputStream |
getOutputStream(String filePath)
Returns an output stream for writing bytes to the file denoted by this path.
|
boolean |
hasChildren(String path)
Tests whether the file system entry denoted by this path has child entries.
|
int |
hashCode()
Returns zero to satisfy the Object equals/hashCode contract.
|
void |
init()
Initialize the file system
|
boolean |
isFile(String path)
Tests whether the file system entry denoted by this path exists and
is a file.
|
boolean |
isFolder(String path)
Tests whether the file system entry denoted by this path exists and
is a folder.
|
long |
lastModified(String path)
Returns the time that the file system entry denoted by this path
was last modified.
|
long |
length(String filePath)
Returns the length of the file denoted by this path.
|
String[] |
list(String folderPath)
Returns an array of strings naming the files and folders
in the folder denoted by this path.
|
String[] |
listFiles(String folderPath)
Returns an array of strings naming the files in the folder
denoted by this path.
|
String[] |
listFolders(String folderPath)
Returns an array of strings naming the folders in the folder
denoted by this path.
|
void |
setBaseFolderUri(String baseFolderUri)
Sets the base VFS folder URI.
|
void |
setConfig(String config)
Set the configuration properties path.
|
void |
setFileSystemManagerClassName(String fileSystemManagerClassName)
Sets the class name of the VFS
FileSystemManager instance used in this VFS file system. |
void |
setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions fileSystemOptions)
Sets the
FileSystemOptions instance used when resolving the baseFolder . |
void |
setFileSystemOptionsProperties(Properties fileSystemOptionsProperties)
Sets the properties used when building a
FileSystemOptions , using DelegatingFileSystemOptionsBuilder . |
void |
setFileSystemOptionsPropertiesInString(String fileSystemOptionsPropertiesInString)
Sets the properties in a semi-colon delimited string used when building a
FileSystemOptions ,
using DelegatingFileSystemOptionsBuilder . |
public String getConfig()
public void setConfig(String config)
config
- path of configuration properties.public String getFileSystemManagerClassName()
FileSystemManager
instance used in this VFS file system.public void setFileSystemManagerClassName(String fileSystemManagerClassName)
FileSystemManager
instance used in this VFS file system.
If this is not set, then StandardFileSystemManager
is used by default.fileSystemManagerClassName
- public org.apache.commons.vfs2.FileSystemManager getFileSystemManager()
FileSystemManager
instance used in this VFS file system.FileSystemManager
instance used in this VFS file systempublic org.apache.commons.vfs2.FileSystemOptions getFileSystemOptions() throws FileSystemException
FileSystemOptions
instance used when resolving the baseFolder
.
This may return null if FileSystemOptions
instance was not injected or
a fileSystemOptionsProperties
instance cannot be injected or created.
Therefore, the caller should check whether or not this returns null.
When returning null, the caller may not use a FileSystemOptions
instance.FileSystemOptions
instance used when resolving the baseFolder
FileSystemException
public void setFileSystemOptions(org.apache.commons.vfs2.FileSystemOptions fileSystemOptions)
FileSystemOptions
instance used when resolving the baseFolder
.fileSystemOptions
- FileSystemOptions
instance used when resolving the baseFolder
public void setFileSystemOptionsProperties(Properties fileSystemOptionsProperties)
FileSystemOptions
, using DelegatingFileSystemOptionsBuilder
.fileSystemOptionsProperties
- properties used when building a FileSystemOptions
public void setFileSystemOptionsPropertiesInString(String fileSystemOptionsPropertiesInString)
FileSystemOptions
,
using DelegatingFileSystemOptionsBuilder
.fileSystemOptionsPropertiesInString
- properties in Stringpublic void setBaseFolderUri(String baseFolderUri)
baseFolderUri
- base VFS folder URIpublic int hashCode()
hashCode
in class Object
Object.hashCode()
public void init() throws FileSystemException
FileSystem
init
in interface FileSystem
FileSystemException
- if the file system initialization failspublic void close() throws FileSystemException
FileSystem
close
in interface FileSystem
FileSystemException
public void createFolder(String folderPath) throws FileSystemException
FileSystem
createFolder
in interface FileSystem
folderPath
- the path of the folder to be created.FileSystemException
- if a file system entry denoted by path
already exists or if another error occurs.public void deleteFile(String filePath) throws FileSystemException
FileSystem
deleteFile
in interface FileSystem
filePath
- the path of the file to be deleted.FileSystemException
- if this path does not denote a file or if
another error occurs.public void deleteFolder(String folderPath) throws FileSystemException
FileSystem
deleteFolder
in interface FileSystem
folderPath
- the path of the folder to be deleted.FileSystemException
- if this path does not denote a folder or if
another error occurs.public boolean exists(String path) throws FileSystemException
FileSystem
exists
in interface FileSystem
path
- the path of a file system entry.FileSystemException
public InputStream getInputStream(String filePath) throws FileSystemException
FileSystem
getInputStream
in interface FileSystem
filePath
- the path of the file.FileSystemException
- if the file does not exist
or if it cannot be read frompublic OutputStream getOutputStream(String filePath) throws FileSystemException
FileSystem
getOutputStream
in interface FileSystem
filePath
- the path of the file.FileSystemException
- if the file cannot be written to or createdpublic boolean hasChildren(String path) throws FileSystemException
FileSystem
hasChildren
in interface FileSystem
path
- the path of a file system entry.FileSystemException
public boolean isFile(String path) throws FileSystemException
FileSystem
isFile
in interface FileSystem
path
- the path of a file system entry.FileSystemException
public boolean isFolder(String path) throws FileSystemException
FileSystem
isFolder
in interface FileSystem
path
- the path of a file system entry.FileSystemException
public long lastModified(String path) throws FileSystemException
FileSystem
lastModified
in interface FileSystem
path
- the path of a file system entry.FileSystemException
- if the file system entry does not exist.public long length(String filePath) throws FileSystemException
FileSystem
length
in interface FileSystem
filePath
- the path of the file.FileSystemException
- if the path does not denote an existing file.public String[] list(String folderPath) throws FileSystemException
FileSystem
list
in interface FileSystem
folderPath
- the path of the folder whose contents is to be listed.FileSystemException
- if this path does not denote a folder or if
another error occurs.public String[] listFiles(String folderPath) throws FileSystemException
FileSystem
listFiles
in interface FileSystem
folderPath
- the path of the folder whose contents is to be listed.FileSystemException
- if this path does not denote a folder or if
another error occurs.public String[] listFolders(String folderPath) throws FileSystemException
FileSystem
listFolders
in interface FileSystem
folderPath
- the path of the folder whose contents is to be listed.FileSystemException
- if this path does not denote a folder or if
another error occurs.protected org.apache.commons.vfs2.FileSystemManager createFileSystemManager() throws FileSystemException
FileSystemManager
instance.FileSystemManager
instance.FileSystemException
- if an error occurs creating the manager.protected org.apache.commons.vfs2.FileSystemOptions createFileSystemOptions() throws FileSystemException
FileSystemOptions
instance which is used when resolving the baseFolder
during the initialization.
If fileSystemOptionsProperties
is available, this scans all the property key names starting with FILE_SYSTEM_OPTIONS_PROP_PREFIX
and uses the rest of the key name after the FILE_SYSTEM_OPTIONS_PROP_PREFIX
as the combination of scheme and property name
when building a FileSystemOptions
using DelegatingFileSystemOptionsBuilder
.FileSystemOptions
instance which is used when resolving the baseFolder
during the initializationFileSystemException
- if any file system exception occursprotected Properties getFileSystemOptionsProperties()
FileSystemOptions
instance by the properties
during the initialization.FileSystemOptions
instance by the properties during the initializationCopyright © 2004–2024 The Apache Software Foundation. All rights reserved.