public interface FsWorker
Defines basic file system operations. Implementations may be based on java.io
, java.nio
, etc., etc.
This interface is currently envisaged for local file system use only.
Modifier and Type | Method and Description |
---|---|
static java.io.File |
checkExists(java.io.File file)
Throw an exception if the file does not exist.
|
static java.io.File |
checkNonExistent(java.io.File file)
Throw an exception if the file exists.
|
static java.io.File |
checkReadable(java.io.File file)
Throw an exception if the file is not readable
|
static java.io.File |
checkWriteable(java.io.File file)
Throw an exception if the file is not readable or writeable
|
default void |
delete(java.io.File file)
Deletes the specified
file . |
byte[] |
get(java.io.File file)
Gets the contents of the specified
File . |
static java.io.File |
isDirectory(java.io.File file)
Throw an exception if the file is not a directory
|
static java.io.File |
isFile(java.io.File file)
Throw an exception if the file is not a plain file.
|
default boolean |
isWriteableDir(java.io.File dir)
Returns true if the passed
File is a writeable directory, otherwise false. |
default java.io.File[] |
listFiles(java.io.File dir)
Returns an array of
File s in directory dir . |
default java.io.File[] |
listFiles(java.io.File dir,
java.io.FileFilter filter)
Returns an array of
File s in directory dir that match the passed filter . |
void |
put(byte[] data,
java.io.File file)
Writes
data to the specified file . |
default void |
rename(java.io.File oldFile,
java.io.File newFile)
Renames
oldfile to newName . |
default java.io.File[] listFiles(java.io.File dir) throws FsException
Returns an array of File
s in directory dir
. If dir
does not exist, if dir
is a file, if dir
has not got appropriate permissions, or if dir
is null a FsException
will be thrown.
dir
- the directory to listFile
sFsException
- wrapping any underlying Exceptiondefault java.io.File[] listFiles(java.io.File dir, java.io.FileFilter filter) throws FsException
Returns an array of File
s in directory dir
that match the passed filter
. If
dir
does not exist, if dir
is a file, if dir
has not got appropriate permissions, or if
dir
is null a FsException
will be thrown.
dir
- the directory to listfilter
- the FileFilter
to applyFile
sFsException
- wrapping any underlying Exceptionbyte[] get(java.io.File file) throws FsException
Gets the contents of the specified File
. If the file doesn't exist or other I/O problems are encountered a
FsException
will be thrown.
file
- the File
to getFsException
- wrapping any underlying Exception that may occurvoid put(byte[] data, java.io.File file) throws FsException
Writes data
to the specified file
. If the named file already exists or if part of the path doesn't
exist a FsException
is thrown.
data
- the data to writefile
- the file to write toFsException
- wrapping any underlying Exception that may occurdefault void rename(java.io.File oldFile, java.io.File newFile) throws FsException
Renames oldfile
to newName
. If oldFile
does not exist or is a directory, or if
newName
already exists an FsException
is thrown.
oldFile
- the file to renamenewFile
- the new name for the fileFsFilenameExistsException
- if newFile existsFsException
- wrapping any underlying Exception that may occurdefault void delete(java.io.File file) throws FsException
Deletes the specified file
. If the file doesn't exist returns quietly.
file
- the file to delete in theFsException
- wrapping any underlying Exception that may occurdefault boolean isWriteableDir(java.io.File dir) throws FsException
Returns true if the passed File
is a writeable directory, otherwise false.
dir
- the directory to check in theFile
is a writeable directory, otherwise falseFsException
- wrapping any underlying Exception that may occurstatic java.io.File checkExists(java.io.File file) throws FsException
FsException
- if the file does not existstatic java.io.File checkNonExistent(java.io.File file) throws FsException
FsException
- if the file existsstatic java.io.File checkReadable(java.io.File file) throws FsException
FsException
static java.io.File checkWriteable(java.io.File file) throws FsException
FsException
static java.io.File isDirectory(java.io.File file) throws FsException
FsException
static java.io.File isFile(java.io.File file) throws FsException
FsException