public interface FileSystem
Modifier and Type | Method and Description |
---|---|
void |
add(FileSystemEntry entry)
Add the specified file system entry (file or directory) to this file system
|
boolean |
delete(String path)
Delete the file or directory specified by the path.
|
boolean |
exists(String path)
Return true if there exists a file or directory at the specified path
|
String |
formatDirectoryListing(FileSystemEntry fileSystemEntry)
Return the formatted directory listing entry for the file represented by the specified FileSystemEntry
|
FileSystemEntry |
getEntry(String path)
Returns the FileSystemEntry object representing the file system entry at the specified path, or null
if the path does not specify an existing file or directory within this file system.
|
String |
getParent(String path)
Return the parent path of the specified path.
|
boolean |
isAbsolute(String path)
Return true if the specified path designates an absolute file path.
|
boolean |
isDirectory(String path)
Return true if the specified path designates an existing directory, false otherwise
|
boolean |
isFile(String path)
Return true if the specified path designates an existing file, false otherwise
|
List |
listFiles(String path)
Return the List of FileSystemEntry objects for the files in the specified directory path.
|
List |
listNames(String path)
Return the List of filenames in the specified directory path.
|
String |
path(String path1,
String path2)
Build a path from the two path components.
|
void |
rename(String fromPath,
String toPath)
Rename the file or directory.
|
void add(FileSystemEntry entry)
entry
- - the FileSystemEntry to addList listFiles(String path)
path
- - the path of the directory whose contents should be returnedList listNames(String path)
path
- - the path of the directory whose contents should be returnedAssertionError
- - if path is nullboolean delete(String path)
path
- - the path of the file or directory to deleteAssertionError
- - if path is nullvoid rename(String fromPath, String toPath)
fromPath
- - the source (old) path + filenametoPath
- - the target (new) path + filenameAssertionError
- - if fromPath or toPath is nullFileSystemException
- - if the rename fails.String formatDirectoryListing(FileSystemEntry fileSystemEntry)
fileSystemEntry
- - the FileSystemEntry representing the file or directory entry to be formattedboolean exists(String path)
path
- - the pathAssertionError
- - if path is nullboolean isDirectory(String path)
path
- - the pathAssertionError
- - if path is nullboolean isFile(String path)
path
- - the pathAssertionError
- - if path is nullboolean isAbsolute(String path)
path
- - the pathAssertionError
- - if path is nullString path(String path1, String path2)
path1
- - the first path component may be null or emptypath2
- - the second path component may be null or emptyFileSystemEntry getEntry(String path)
path
- - the path of the file or directory within this file systemString getParent(String path)
path
specifies a filename,
then this method returns the path of the directory containing that file. If path
specifies a directory, the this method returns its parent directory. If path
is
empty or does not have a parent component, then return an empty string.
All path separators in the returned path are converted to the system-dependent separator character.
path
- - the pathpath
has no parentAssertionError
- - if path is nullCopyright © 2016. All rights reserved.