public class BasedFileSystem extends Object implements FileSystem
BasedFileSystem represents a 'file system in a file system'.| Modifier and Type | Field and Description | 
|---|---|
protected String | 
basePath  | 
protected FileSystem | 
fsBase  | 
SEPARATOR, SEPARATOR_CHAR| Constructor and Description | 
|---|
BasedFileSystem(FileSystem fsBase,
               String relRootPath)
Creates a new  
BasedFileSystem | 
| Modifier and Type | Method and Description | 
|---|---|
protected String | 
buildBasePath(String path)  | 
void | 
close()
Close the file system. 
 | 
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 | 
exists(String path)
Tests whether the file system entry denoted by this path exists. 
 | 
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. 
 | 
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. 
 | 
protected final FileSystem fsBase
protected final String basePath
public BasedFileSystem(FileSystem fsBase, String relRootPath)
BasedFileSystemfsBase - the FileSystem the new file system should be based onrelRootPath - the root path relative to fsBase's rootpublic void init()
          throws FileSystemException
init in interface FileSystemFileSystemException - if the file system initialization failspublic void close()
           throws FileSystemException
close in interface FileSystemFileSystemExceptionpublic void createFolder(String folderPath) throws FileSystemException
createFolder in interface FileSystemfolderPath - 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
deleteFile in interface FileSystemfilePath - 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
deleteFolder in interface FileSystemfolderPath - 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
exists in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic InputStream getInputStream(String filePath) throws FileSystemException
getInputStream in interface FileSystemfilePath - 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
getOutputStream in interface FileSystemfilePath - the path of the file.FileSystemException - if the file cannot be written to or createdpublic boolean hasChildren(String path) throws FileSystemException
hasChildren in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic boolean isFile(String path) throws FileSystemException
isFile in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic boolean isFolder(String path) throws FileSystemException
isFolder in interface FileSystempath - the path of a file system entry.FileSystemExceptionpublic long lastModified(String path) throws FileSystemException
lastModified in interface FileSystempath - the path of a file system entry.FileSystemException - if the file system entry does not exist.public long length(String filePath) throws FileSystemException
length in interface FileSystemfilePath - the path of the file.FileSystemException - if the path does not denote an existing file.public String[] list(String folderPath) throws FileSystemException
list in interface FileSystemfolderPath - 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
listFiles in interface FileSystemfolderPath - 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
listFolders in interface FileSystemfolderPath - 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.Copyright © 2004–2021 The Apache Software Foundation. All rights reserved.