public interface FileSystem
Contains a broad set of operations for manipulating files.<p> A blocking and non blocking version of each operation is provided.<p> The non blocking versions take a handler which is called when the operation completes or an error occurs.<p> The blocking versions return the results, or throw exceptions directly.<p> It is highly recommended the non blocking versions are used unless you are sure the operation will not block for a significant period of time.<p> Instances of FileSystem are thread-safe.<p>
Modifier and Type | Method and Description |
---|---|
FileSystem |
chmod(String path,
String perms,
Handler<AsyncResult<Void>> handler)
Change the permissions on the file represented by
path to perms , asynchronously. |
FileSystem |
chmodBlocking(String path,
String perms)
Blocking version of
chmod(String, String, Handler) |
FileSystem |
chmodRecursive(String path,
String perms,
String dirPerms,
Handler<AsyncResult<Void>> handler)
Change the permissions on the file represented by
path to perms , asynchronously. |
FileSystem |
chmodRecursiveBlocking(String path,
String perms,
String dirPerms)
Blocking version of
chmodRecursive(String, String, String, Handler) |
FileSystem |
chown(String path,
String user,
String group,
Handler<AsyncResult<Void>> handler)
Change the ownership on the file represented by
path to user and {code group}, asynchronously. |
FileSystem |
chownBlocking(String path,
String user,
String group)
Blocking version of
chown(String, String, String, Handler) |
FileSystem |
copy(String from,
String to,
Handler<AsyncResult<Void>> handler)
Copy a file from the path
from to path to , asynchronously.<p>
The copy will fail if the destination already exists.<p> |
FileSystem |
copyBlocking(String from,
String to)
Blocking version of
copy(String, String, Handler) |
FileSystem |
copyRecursive(String from,
String to,
boolean recursive,
Handler<AsyncResult<Void>> handler)
Copy a file from the path
from to path to , asynchronously.<p>
If recursive is true and from represents a directory, then the directory and its contents
will be copied recursively to the destination to .<p>
The copy will fail if the destination if the destination already exists.<p> |
FileSystem |
copyRecursiveBlocking(String from,
String to,
boolean recursive)
Blocking version of
copyRecursive(String, String, boolean, Handler) |
FileSystem |
createFile(String path,
Handler<AsyncResult<Void>> handler)
Creates an empty file with the specified
path , asynchronously. |
FileSystem |
createFile(String path,
String perms,
Handler<AsyncResult<Void>> handler)
Creates an empty file with the specified
path and permissions perms , asynchronously. |
FileSystem |
createFileBlocking(String path)
Blocking version of
createFile(String, Handler) |
FileSystem |
createFileBlocking(String path,
String perms)
Blocking version of
createFile(String, String, Handler) |
FileSystem |
delete(String path,
Handler<AsyncResult<Void>> handler)
Deletes the file represented by the specified
path , asynchronously. |
FileSystem |
deleteBlocking(String path)
Blocking version of
delete(String, Handler) |
FileSystem |
deleteRecursive(String path,
boolean recursive,
Handler<AsyncResult<Void>> handler)
Deletes the file represented by the specified
path , asynchronously.<p>
If the path represents a directory and recursive = true then the directory and its contents will be
deleted recursively. |
FileSystem |
deleteRecursiveBlocking(String path,
boolean recursive)
Blocking version of
deleteRecursive(String, boolean, Handler) |
FileSystem |
exists(String path,
Handler<AsyncResult<Boolean>> handler)
Determines whether the file as specified by the path
path exists, asynchronously. |
boolean |
existsBlocking(String path)
Blocking version of
exists(String, Handler) |
FileSystem |
fsProps(String path,
Handler<AsyncResult<FileSystemProps>> handler)
Returns properties of the file-system being used by the specified
path , asynchronously. |
FileSystemProps |
fsPropsBlocking(String path)
Blocking version of
fsProps(String, Handler) |
FileSystem |
link(String link,
String existing,
Handler<AsyncResult<Void>> handler)
Create a hard link on the file system from
link to existing , asynchronously. |
FileSystem |
linkBlocking(String link,
String existing)
Blocking version of
link(String, String, Handler) |
FileSystem |
lprops(String path,
Handler<AsyncResult<FileProps>> handler)
Obtain properties for the link represented by
path , asynchronously. |
FileProps |
lpropsBlocking(String path)
Blocking version of
lprops(String, Handler) |
FileSystem |
mkdir(String path,
Handler<AsyncResult<Void>> handler)
Create the directory represented by
path , asynchronously.<p>
The operation will fail if the directory already exists. |
FileSystem |
mkdir(String path,
String perms,
Handler<AsyncResult<Void>> handler)
Create the directory represented by
path , asynchronously.<p>
The new directory will be created with permissions as specified by perms . |
FileSystem |
mkdirBlocking(String path)
Blocking version of
mkdir(String, Handler) |
FileSystem |
mkdirBlocking(String path,
String perms)
Blocking version of
mkdir(String, String, Handler) |
FileSystem |
mkdirs(String path,
Handler<AsyncResult<Void>> handler)
Create the directory represented by
path , asynchronously.<p>
If createParents is set to true then any non-existent parent directories of the directory
will also be created.<p>
The operation will fail if the directory already exists. |
FileSystem |
mkdirs(String path,
String perms,
Handler<AsyncResult<Void>> handler)
Create the directory represented by
path , asynchronously.<p>
The new directory will be created with permissions as specified by perms . |
FileSystem |
mkdirsBlocking(String path)
Blocking version of
mkdirs(String, Handler) |
FileSystem |
mkdirsBlocking(String path,
String perms)
Blocking version of
mkdirs(String, String, Handler) |
FileSystem |
move(String from,
String to,
Handler<AsyncResult<Void>> handler)
Move a file from the path
from to path to , asynchronously.<p>
The move will fail if the destination already exists.<p> |
FileSystem |
moveBlocking(String from,
String to)
Blocking version of
move(String, String, Handler) |
FileSystem |
open(String path,
OpenOptions options,
Handler<AsyncResult<AsyncFile>> handler)
Open the file represented by
path , asynchronously.<p>
The file is opened for both reading and writing. |
AsyncFile |
openBlocking(String path,
OpenOptions options)
Blocking version of
open(String, io.vertx.core.file.OpenOptions, Handler) |
FileSystem |
props(String path,
Handler<AsyncResult<FileProps>> handler)
Obtain properties for the file represented by
path , asynchronously. |
FileProps |
propsBlocking(String path)
Blocking version of
props(String, Handler) |
FileSystem |
readDir(String path,
Handler<AsyncResult<List<String>>> handler)
Read the contents of the directory specified by
path , asynchronously.<p>
The result is an array of String representing the paths of the files inside the directory. |
FileSystem |
readDir(String path,
String filter,
Handler<AsyncResult<List<String>>> handler)
Read the contents of the directory specified by
path , asynchronously.<p>
The parameter filter is a regular expression. |
List<String> |
readDirBlocking(String path)
Blocking version of
readDir(String, Handler) |
List<String> |
readDirBlocking(String path,
String filter)
Blocking version of
readDir(String, String, Handler) |
FileSystem |
readFile(String path,
Handler<AsyncResult<Buffer>> handler)
Reads the entire file as represented by the path
path as a Buffer , asynchronously.<p>
Do not user this method to read very large files or you risk running out of available RAM. |
Buffer |
readFileBlocking(String path)
Blocking version of
readFile(String, Handler) |
FileSystem |
readSymlink(String link,
Handler<AsyncResult<String>> handler)
Returns the path representing the file that the symbolic link specified by
link points to, asynchronously. |
String |
readSymlinkBlocking(String link)
Blocking version of
readSymlink(String, Handler) |
FileSystem |
symlink(String link,
String existing,
Handler<AsyncResult<Void>> handler)
Create a symbolic link on the file system from
link to existing , asynchronously. |
FileSystem |
symlinkBlocking(String link,
String existing)
Blocking version of
link(String, String, Handler) |
FileSystem |
truncate(String path,
long len,
Handler<AsyncResult<Void>> handler)
Truncate the file represented by
path to length len in bytes, asynchronously.<p>
The operation will fail if the file does not exist or len is less than zero . |
FileSystem |
truncateBlocking(String path,
long len)
Blocking version of
truncate(String, long, Handler) |
FileSystem |
unlink(String link,
Handler<AsyncResult<Void>> handler)
Unlinks the link on the file system represented by the path
link , asynchronously. |
FileSystem |
unlinkBlocking(String link)
Blocking version of
unlink(String, Handler) |
FileSystem |
writeFile(String path,
Buffer data,
Handler<AsyncResult<Void>> handler)
Creates the file, and writes the specified
Buffer data to the file represented by the path path ,
asynchronously. |
FileSystem |
writeFileBlocking(String path,
Buffer data)
Blocking version of
writeFile(String, Buffer, Handler) |
FileSystem copy(String from, String to, Handler<AsyncResult<Void>> handler)
Copy a file from the path from
to path to
, asynchronously.<p>
The copy will fail if the destination already exists.<p>
FileSystem copyBlocking(String from, String to)
Blocking version of copy(String, String, Handler)
FileSystem copyRecursive(String from, String to, boolean recursive, Handler<AsyncResult<Void>> handler)
Copy a file from the path from
to path to
, asynchronously.<p>
If recursive
is true
and from
represents a directory, then the directory and its contents
will be copied recursively to the destination to
.<p>
The copy will fail if the destination if the destination already exists.<p>
FileSystem copyRecursiveBlocking(String from, String to, boolean recursive)
Blocking version of copyRecursive(String, String, boolean, Handler)
FileSystem move(String from, String to, Handler<AsyncResult<Void>> handler)
Move a file from the path from
to path to
, asynchronously.<p>
The move will fail if the destination already exists.<p>
FileSystem moveBlocking(String from, String to)
Blocking version of move(String, String, Handler)
FileSystem truncate(String path, long len, Handler<AsyncResult<Void>> handler)
Truncate the file represented by path
to length len
in bytes, asynchronously.<p>
The operation will fail if the file does not exist or len
is less than zero
.
FileSystem truncateBlocking(String path, long len)
Blocking version of truncate(String, long, Handler)
FileSystem chmod(String path, String perms, Handler<AsyncResult<Void>> handler)
Change the permissions on the file represented by path
to perms
, asynchronously.
The permission String takes the form rwxr-x--- as
specified <a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>.<p>
FileSystem chmodBlocking(String path, String perms)
Blocking version of chmod(String, String, Handler)
FileSystem chmodRecursive(String path, String perms, String dirPerms, Handler<AsyncResult<Void>> handler)
Change the permissions on the file represented by path
to perms
, asynchronously.
The permission String takes the form rwxr-x--- as
specified in {<a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>}.<p>
If the file is directory then all contents will also have their permissions changed recursively. Any directory permissions will
be set to dirPerms
, whilst any normal file permissions will be set to perms
.<p>
FileSystem chmodRecursiveBlocking(String path, String perms, String dirPerms)
Blocking version of chmodRecursive(String, String, String, Handler)
FileSystem chown(String path, String user, String group, Handler<AsyncResult<Void>> handler)
Change the ownership on the file represented by path
to user
and {code group}, asynchronously.
FileSystem chownBlocking(String path, String user, String group)
Blocking version of chown(String, String, String, Handler)
FileSystem props(String path, Handler<AsyncResult<FileProps>> handler)
Obtain properties for the file represented by path
, asynchronously.
If the file is a link, the link will be followed.
FileProps propsBlocking(String path)
Blocking version of props(String, Handler)
FileSystem lprops(String path, Handler<AsyncResult<FileProps>> handler)
Obtain properties for the link represented by path
, asynchronously.
The link will not be followed.
FileProps lpropsBlocking(String path)
Blocking version of lprops(String, Handler)
FileSystem link(String link, String existing, Handler<AsyncResult<Void>> handler)
Create a hard link on the file system from link
to existing
, asynchronously.
FileSystem linkBlocking(String link, String existing)
Blocking version of link(String, String, Handler)
FileSystem symlink(String link, String existing, Handler<AsyncResult<Void>> handler)
Create a symbolic link on the file system from link
to existing
, asynchronously.
FileSystem symlinkBlocking(String link, String existing)
Blocking version of link(String, String, Handler)
FileSystem unlink(String link, Handler<AsyncResult<Void>> handler)
Unlinks the link on the file system represented by the path link
, asynchronously.
FileSystem unlinkBlocking(String link)
Blocking version of unlink(String, Handler)
FileSystem readSymlink(String link, Handler<AsyncResult<String>> handler)
Returns the path representing the file that the symbolic link specified by link
points to, asynchronously.
String readSymlinkBlocking(String link)
Blocking version of readSymlink(String, Handler)
FileSystem delete(String path, Handler<AsyncResult<Void>> handler)
Deletes the file represented by the specified path
, asynchronously.
FileSystem deleteBlocking(String path)
Blocking version of delete(String, Handler)
FileSystem deleteRecursive(String path, boolean recursive, Handler<AsyncResult<Void>> handler)
Deletes the file represented by the specified path
, asynchronously.<p>
If the path represents a directory and recursive = true
then the directory and its contents will be
deleted recursively.
FileSystem deleteRecursiveBlocking(String path, boolean recursive)
Blocking version of deleteRecursive(String, boolean, Handler)
FileSystem mkdir(String path, Handler<AsyncResult<Void>> handler)
Create the directory represented by path
, asynchronously.<p>
The operation will fail if the directory already exists.
FileSystem mkdirBlocking(String path)
Blocking version of mkdir(String, Handler)
FileSystem mkdir(String path, String perms, Handler<AsyncResult<Void>> handler)
Create the directory represented by path
, asynchronously.<p>
The new directory will be created with permissions as specified by perms
.
The permission String takes the form rwxr-x--- as specified
in <a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>.<p>
The operation will fail if the directory already exists.
FileSystem mkdirBlocking(String path, String perms)
Blocking version of mkdir(String, String, Handler)
FileSystem mkdirs(String path, Handler<AsyncResult<Void>> handler)
Create the directory represented by path
, asynchronously.<p>
If createParents
is set to true
then any non-existent parent directories of the directory
will also be created.<p>
The operation will fail if the directory already exists.
FileSystem mkdirsBlocking(String path)
Blocking version of mkdirs(String, Handler)
FileSystem mkdirs(String path, String perms, Handler<AsyncResult<Void>> handler)
Create the directory represented by path
, asynchronously.<p>
The new directory will be created with permissions as specified by perms
.
The permission String takes the form rwxr-x--- as specified
in <a href="http://download.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFilePermissions.html">here</a>.<p>
If createParents
is set to true
then any non-existent parent directories of the directory
will also be created.<p>
The operation will fail if the directory already exists.<p>
FileSystem mkdirsBlocking(String path, String perms)
Blocking version of mkdirs(String, String, Handler)
FileSystem readDir(String path, Handler<AsyncResult<List<String>>> handler)
Read the contents of the directory specified by path
, asynchronously.<p>
The result is an array of String representing the paths of the files inside the directory.
List<String> readDirBlocking(String path)
Blocking version of readDir(String, Handler)
FileSystem readDir(String path, String filter, Handler<AsyncResult<List<String>>> handler)
Read the contents of the directory specified by path
, asynchronously.<p>
The parameter filter
is a regular expression. If filter
is specified then only the paths that
match @{filter}will be returned.<p>
The result is an array of String representing the paths of the files inside the directory.
List<String> readDirBlocking(String path, String filter)
Blocking version of readDir(String, String, Handler)
FileSystem readFile(String path, Handler<AsyncResult<Buffer>> handler)
Reads the entire file as represented by the path path
as a Buffer
, asynchronously.<p>
Do not user this method to read very large files or you risk running out of available RAM.
Buffer readFileBlocking(String path)
Blocking version of readFile(String, Handler)
FileSystem writeFile(String path, Buffer data, Handler<AsyncResult<Void>> handler)
Creates the file, and writes the specified Buffer data
to the file represented by the path path
,
asynchronously.
FileSystem writeFileBlocking(String path, Buffer data)
Blocking version of writeFile(String, Buffer, Handler)
FileSystem open(String path, OpenOptions options, Handler<AsyncResult<AsyncFile>> handler)
Open the file represented by path
, asynchronously.<p>
The file is opened for both reading and writing. If the file does not already exist it will be created.
Write operations will not automatically flush to storage.
AsyncFile openBlocking(String path, OpenOptions options)
Blocking version of open(String, io.vertx.core.file.OpenOptions, Handler)
FileSystem createFile(String path, Handler<AsyncResult<Void>> handler)
Creates an empty file with the specified path
, asynchronously.
FileSystem createFileBlocking(String path)
Blocking version of createFile(String, Handler)
FileSystem createFile(String path, String perms, Handler<AsyncResult<Void>> handler)
Creates an empty file with the specified path
and permissions perms
, asynchronously.
FileSystem createFileBlocking(String path, String perms)
Blocking version of createFile(String, String, Handler)
FileSystem exists(String path, Handler<AsyncResult<Boolean>> handler)
Determines whether the file as specified by the path path
exists, asynchronously.
boolean existsBlocking(String path)
Blocking version of exists(String, Handler)
FileSystem fsProps(String path, Handler<AsyncResult<FileSystemProps>> handler)
Returns properties of the file-system being used by the specified path
, asynchronously.
FileSystemProps fsPropsBlocking(String path)
Blocking version of fsProps(String, Handler)
Copyright © 2014. All Rights Reserved.