public interface FileSystem
| Modifier and Type | Interface and Description |
|---|---|
static class |
FileSystem.OpenState
Enumeration representing the three possible states of a file system.
|
| Modifier and Type | Method and Description |
|---|---|
void |
chdir(java.lang.String path)
Changes the current directory.
|
void |
close()
Stops the interaction with the file system.
|
void |
delete(java.lang.String path)
Deletes a directory and all its contents.
|
long |
getSize(java.lang.String path)
Gets the size of a file.
|
boolean |
isDirectory(java.lang.String path)
Determines if the resource pointed to by a given path corresponds to a
directory.
|
boolean |
isFile(java.lang.String path)
Determines if the resource pointed to by a given path corresponds to a
file.
|
java.util.List<java.lang.String> |
ls()
Lists all the files and folders in the current directory.
|
java.util.List<java.lang.String> |
ls(java.lang.String path)
Lists all the files and folders in a given directory.
|
void |
mkdir(java.lang.String path)
Creates a directory if it does not exist.
|
void |
open()
Starts the interaction with the file system.
|
void |
popd()
Changes the current directory to the one before the last call to
chdir(String) or pushd(String). |
void |
pushd(java.lang.String path) |
java.lang.String |
pwd()
Retrieves the current working directory, relative to the root of the
file system.
|
java.io.InputStream |
readFrom(java.lang.String filename)
Reads data from a file.
|
void |
rmdir(java.lang.String path)
Deletes a directory and all its contents.
|
java.io.OutputStream |
writeTo(java.lang.String filename)
Writes data to a file.
|
void open() throws FileSystemException
FileSystemException if called before
this method.FileSystemException - Thrown if the interaction with the file system
cannot be startedjava.util.List<java.lang.String> ls()
throws FileSystemException
FileSystemException - Thrown if the operation could not be performed
for some reasonjava.util.List<java.lang.String> ls(java.lang.String path)
throws FileSystemException
path - The path from which to list filesFileSystemException - Thrown if the operation could not be performed
for some reasonboolean isDirectory(java.lang.String path)
throws FileSystemException
path - The pathFileSystemException - Thrown if the operation could not be performed
for some reasonboolean isFile(java.lang.String path)
throws FileSystemException
path - The pathFileSystemException - Thrown if the operation could not be performed
for some reasonlong getSize(java.lang.String path)
throws FileSystemException
path - The path corresponding to the fileFileSystemException - Thrown if the operation could not be performed
for some reasonjava.io.OutputStream writeTo(java.lang.String filename)
throws FileSystemException
OutputStream to
which data can be printed. The data is guaranteed to be committed to the
file only when the print stream is closed. Whether data is written before
that moment depends on the actual file system implementation.filename - The name of the file to which data is to be writtenFileSystemException - Thrown if the operation could not be performed
for some reasonjava.io.InputStream readFrom(java.lang.String filename)
throws FileSystemException
InputStream from
which data can be read. Consumers of this input stream have the
responsibility to close the stream after usage.filename - The name of the file to which data is to be writtenFileSystemException - Thrown if the operation could not be performed
for some reasonvoid chdir(java.lang.String path)
throws FileSystemException
path - The directory to change to. The string can contain a path
relative to the current directory.FileSystemException - Thrown if the operation could not be performed
for some reasonvoid pushd(java.lang.String path)
throws FileSystemException
path - The directory to change to. The string can contain a path
relative to the current directory.FileSystemException - Thrown if the operation could not be performed
for some reasonvoid popd() throws FileSystemException
chdir(String) or pushd(String).FileSystemException - Thrown if the operation could not be performed
for some reasonvoid mkdir(java.lang.String path)
throws FileSystemException
path - The directory to create. The string can contain a path
relative to the current directory.FileSystemException - Thrown if the operation could not be performed
for some reasonvoid rmdir(java.lang.String path)
throws FileSystemException
path - The directory to deleteFileSystemException - Thrown if the operation could not be performed
for some reasonvoid delete(java.lang.String path)
throws FileSystemException
path - The directory to deleteFileSystemException - Thrown if the operation could not be performed
for some reasonjava.lang.String pwd()
throws FileSystemException
FileSystemException - Thrown if the operation could not be performed
for some reasonvoid close()
throws FileSystemException
FileSystemException if called after
this method.FileSystemException - Thrown if an error occurred while stopping the
interaction with the file systemCopyright © Sylvain HallĂ©. All Rights Reserved.