Contains a broad set of operations for manipulating files on the file system.
A (potential) blocking and non blocking version of each operation is provided.
The non blocking versions take a handler which is called when the operation completes or an error occurs.
The blocking versions are named xxxBlocking
and return the results, or throw exceptions directly.
In many cases, depending on the operating system and file system some of the potentially blocking operations
can return quickly, which is why we provide them, but it's highly recommended that you test how long they take to
return in your particular application before using them on an event loop.
Please consult the documentation for more information on file system support.
Constructor and description |
---|
FileSystem
(java.lang.Object delegate) |
Type | Name and description |
---|---|
FileSystem |
chmod(java.lang.String path, java.lang.String perms, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Change the permissions on the file represented by path to perms , asynchronously. |
FileSystem |
chmodBlocking(java.lang.String path, java.lang.String perms) Blocking version of #chmod(String, String, Handler) |
FileSystem |
chmodRecursive(java.lang.String path, java.lang.String perms, java.lang.String dirPerms, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Change the permissions on the file represented by path to perms , asynchronously. |
FileSystem |
chmodRecursiveBlocking(java.lang.String path, java.lang.String perms, java.lang.String dirPerms) Blocking version of FileSystem.chmodRecursive |
FileSystem |
chown(java.lang.String path, java.lang.String user, java.lang.String group, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Change the ownership on the file represented by path to user and {code group}, asynchronously. |
FileSystem |
chownBlocking(java.lang.String path, java.lang.String user, java.lang.String group) Blocking version of |
FileSystem |
copy(java.lang.String from, java.lang.String to, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Copy a file from the path from to path to , asynchronously. |
FileSystem |
copyBlocking(java.lang.String from, java.lang.String to) Blocking version of FileSystem.copy |
FileSystem |
copyRecursive(java.lang.String from, java.lang.String to, boolean recursive, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Copy a file from the path from to path to , asynchronously. |
FileSystem |
copyRecursiveBlocking(java.lang.String from, java.lang.String to, boolean recursive) Blocking version of FileSystem.copyRecursive |
FileSystem |
createFile(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Creates an empty file with the specified path , asynchronously. |
FileSystem |
createFile(java.lang.String path, java.lang.String perms, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Creates an empty file with the specified path and permissions perms , asynchronously. |
FileSystem |
createFileBlocking(java.lang.String path) Blocking version of FileSystem.createFile |
FileSystem |
createFileBlocking(java.lang.String path, java.lang.String perms) Blocking version of FileSystem.createFile |
FileSystem |
delete(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Deletes the file represented by the specified path , asynchronously. |
FileSystem |
deleteBlocking(java.lang.String path) Blocking version of FileSystem.delete |
FileSystem |
deleteRecursive(java.lang.String path, boolean recursive, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Deletes the file represented by the specified path , asynchronously. |
FileSystem |
deleteRecursiveBlocking(java.lang.String path, boolean recursive) Blocking version of FileSystem.deleteRecursive |
FileSystem |
exists(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Boolean>> handler) Determines whether the file as specified by the path path exists, asynchronously. |
boolean |
existsBlocking(java.lang.String path) Blocking version of FileSystem.exists |
FileSystem |
fsProps(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<FileSystemProps>> handler) Returns properties of the file-system being used by the specified path , asynchronously. |
FileSystemProps |
fsPropsBlocking(java.lang.String path) Blocking version of FileSystem.fsProps |
java.lang.Object |
getDelegate() |
FileSystem |
link(java.lang.String link, java.lang.String existing, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Create a hard link on the file system from link to existing , asynchronously. |
FileSystem |
linkBlocking(java.lang.String link, java.lang.String existing) Blocking version of FileSystem.link |
FileSystem |
lprops(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<FileProps>> handler) Obtain properties for the link represented by path , asynchronously. |
FileProps |
lpropsBlocking(java.lang.String path) Blocking version of FileSystem.lprops |
FileSystem |
mkdir(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Create the directory represented by path , asynchronously. |
FileSystem |
mkdir(java.lang.String path, java.lang.String perms, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Create the directory represented by path , asynchronously. |
FileSystem |
mkdirBlocking(java.lang.String path) Blocking version of FileSystem.mkdir |
FileSystem |
mkdirBlocking(java.lang.String path, java.lang.String perms) Blocking version of FileSystem.mkdir |
FileSystem |
mkdirs(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Create the directory represented by path and any non existent parents, asynchronously. |
FileSystem |
mkdirs(java.lang.String path, java.lang.String perms, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Create the directory represented by path and any non existent parents, asynchronously. |
FileSystem |
mkdirsBlocking(java.lang.String path) Blocking version of FileSystem.mkdirs |
FileSystem |
mkdirsBlocking(java.lang.String path, java.lang.String perms) Blocking version of FileSystem.mkdirs |
FileSystem |
move(java.lang.String from, java.lang.String to, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Move a file from the path from to path to , asynchronously. |
FileSystem |
moveBlocking(java.lang.String from, java.lang.String to) Blocking version of FileSystem.move |
FileSystem |
open(java.lang.String path, java.util.Map<java.lang.String, java.lang.Object> options, io.vertx.core.Handler<io.vertx.core.AsyncResult<AsyncFile>> handler) Open the file represented by path , asynchronously. |
AsyncFile |
openBlocking(java.lang.String path, java.util.Map<java.lang.String, java.lang.Object> options) Blocking version of FileSystem.open |
FileSystem |
props(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<FileProps>> handler) Obtain properties for the file represented by path , asynchronously. |
FileProps |
propsBlocking(java.lang.String path) Blocking version of FileSystem.props |
FileSystem |
readDir(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.String>>> handler) Read the contents of the directory specified by path , asynchronously. |
FileSystem |
readDir(java.lang.String path, java.lang.String filter, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.util.List<java.lang.String>>> handler) Read the contents of the directory specified by path , asynchronously. |
java.util.List<java.lang.String> |
readDirBlocking(java.lang.String path) Blocking version of FileSystem.readDir |
java.util.List<java.lang.String> |
readDirBlocking(java.lang.String path, java.lang.String filter) Blocking version of FileSystem.readDir |
FileSystem |
readFile(java.lang.String path, io.vertx.core.Handler<io.vertx.core.AsyncResult<Buffer>> handler) Reads the entire file as represented by the path path as a , asynchronously. |
Buffer |
readFileBlocking(java.lang.String path) Blocking version of FileSystem.readFile |
FileSystem |
readSymlink(java.lang.String link, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>> handler) Returns the path representing the file that the symbolic link specified by link points to, asynchronously. |
java.lang.String |
readSymlinkBlocking(java.lang.String link) Blocking version of FileSystem.readSymlink |
FileSystem |
symlink(java.lang.String link, java.lang.String existing, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Create a symbolic link on the file system from link to existing , asynchronously. |
FileSystem |
symlinkBlocking(java.lang.String link, java.lang.String existing) Blocking version of FileSystem.link |
FileSystem |
truncate(java.lang.String path, long len, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Truncate the file represented by path to length len in bytes, asynchronously. |
FileSystem |
truncateBlocking(java.lang.String path, long len) Blocking version of FileSystem.truncate |
FileSystem |
unlink(java.lang.String link, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Unlinks the link on the file system represented by the path link , asynchronously. |
FileSystem |
unlinkBlocking(java.lang.String link) Blocking version of FileSystem.unlink |
FileSystem |
writeFile(java.lang.String path, Buffer data, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.Void>> handler) Creates the file, and writes the specified Buffer data to the file represented by the path path ,
asynchronously. |
FileSystem |
writeFileBlocking(java.lang.String path, Buffer data) Blocking version of FileSystem.writeFile |
Methods inherited from class | Name |
---|---|
class java.lang.Object |
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll() |
Change the permissions on the file represented by path
to perms
, asynchronously.
The permission String takes the form rwxr-x--- as specified here.
path
- the path to the fileperms
- the permissions stringhandler
- the handler that will be called on completionBlocking version of #chmod(String, String, Handler)
Change the permissions on the file represented by path
to perms
, asynchronously.
The permission String takes the form rwxr-x--- as specified in {here}.
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
.
path
- the path to the fileperms
- the permissions stringdirPerms
- the directory permissionshandler
- the handler that will be called on completionBlocking version of FileSystem.chmodRecursive
Change the ownership on the file represented by path
to user
and {code group}, asynchronously.
path
- the path to the fileuser
- the user name, null
will not change the user namegroup
- the user group, null
will not change the user group namehandler
- the handler that will be called on completionBlocking version of
Copy a file from the path from
to path to
, asynchronously.
The copy will fail if the destination already exists.
from
- the path to copy fromto
- the path to copy tohandler
- the handler that will be called on completionBlocking version of FileSystem.copy
Copy a file from the path from
to path to
, asynchronously.
If recursive
is true
and from
represents a directory, then the directory and its contents
will be copied recursively to the destination to
.
The copy will fail if the destination if the destination already exists.
from
- the path to copy fromto
- the path to copy tohandler
- the handler that will be called on completionBlocking version of FileSystem.copyRecursive
Creates an empty file with the specified path
, asynchronously.
path
- path to the filehandler
- the handler that will be called on completion Creates an empty file with the specified path
and permissions perms
, asynchronously.
path
- path to the fileperms
- the permissions stringhandler
- the handler that will be called on completionBlocking version of FileSystem.createFile
Blocking version of FileSystem.createFile
Deletes the file represented by the specified path
, asynchronously.
path
- path to the filehandler
- the handler that will be called on completionBlocking version of FileSystem.delete
Deletes the file represented by the specified path
, asynchronously.
If the path represents a directory and recursive = true
then the directory and its contents will be
deleted recursively.
path
- path to the filerecursive
- delete recursively?handler
- the handler that will be called on completionBlocking version of FileSystem.deleteRecursive
Determines whether the file as specified by the path path
exists, asynchronously.
path
- path to the filehandler
- the handler that will be called on completionBlocking version of FileSystem.exists
Returns properties of the file-system being used by the specified path
, asynchronously.
path
- path to anywhere on the filesystemhandler
- the handler that will be called on completionBlocking version of FileSystem.fsProps
Create a hard link on the file system from link
to existing
, asynchronously.
link
- the linkexisting
- the link destinationhandler
- the handler that will be called on completionBlocking version of FileSystem.link
Obtain properties for the link represented by path
, asynchronously.
The link will not be followed.
path
- the path to the filehandler
- the handler that will be called on completionBlocking version of FileSystem.lprops
Create the directory represented by path
, asynchronously.
The operation will fail if the directory already exists.
path
- path to the filehandler
- the handler that will be called on completion Create the directory represented by path
, asynchronously.
The new directory will be created with permissions as specified by perms
.
The permission String takes the form rwxr-x--- as specified in here.
The operation will fail if the directory already exists.
path
- path to the fileperms
- the permissions stringhandler
- the handler that will be called on completionBlocking version of FileSystem.mkdir
Blocking version of FileSystem.mkdir
Create the directory represented by path
and any non existent parents, asynchronously.
The operation will fail if the directory already exists.
path
- path to the filehandler
- the handler that will be called on completion Create the directory represented by path
and any non existent parents, asynchronously.
The new directory will be created with permissions as specified by perms
.
The permission String takes the form rwxr-x--- as specified in here.
The operation will fail if the directory already exists.
path
- path to the fileperms
- the permissions stringhandler
- the handler that will be called on completionBlocking version of FileSystem.mkdirs
Blocking version of FileSystem.mkdirs
Move a file from the path from
to path to
, asynchronously.
The move will fail if the destination already exists.
from
- the path to copy fromto
- the path to copy tohandler
- the handler that will be called on completionBlocking version of FileSystem.move
Open the file represented by path
, asynchronously.
The file is opened for both reading and writing. If the file does not already exist it will be created.
path
- path to the fileoptions
- options describing how the file should be opened (see OpenOptions)Blocking version of FileSystem.open
options
- (see OpenOptions) Obtain properties for the file represented by path
, asynchronously.
If the file is a link, the link will be followed.
path
- the path to the filehandler
- the handler that will be called on completionBlocking version of FileSystem.props
Read the contents of the directory specified by path
, asynchronously.
The result is an array of String representing the paths of the files inside the directory.
path
- path to the filehandler
- the handler that will be called on completion Read the contents of the directory specified by path
, asynchronously.
The parameter filter
is a regular expression. If filter
is specified then only the paths that
match @{filter}will be returned.
The result is an array of String representing the paths of the files inside the directory.
path
- path to the directoryfilter
- the filter expressionhandler
- the handler that will be called on completionBlocking version of FileSystem.readDir
Blocking version of FileSystem.readDir
Reads the entire file as represented by the path path
as a , asynchronously.
Do not user this method to read very large files or you risk running out of available RAM.
path
- path to the filehandler
- the handler that will be called on completionBlocking version of FileSystem.readFile
Returns the path representing the file that the symbolic link specified by link
points to, asynchronously.
link
- the linkhandler
- the handler that will be called on completionBlocking version of FileSystem.readSymlink
Create a symbolic link on the file system from link
to existing
, asynchronously.
link
- the linkexisting
- the link destinationhandler
- the handler that will be called on completionBlocking version of FileSystem.link
Truncate the file represented by path
to length len
in bytes, asynchronously.
The operation will fail if the file does not exist or len
is less than zero
.
path
- the path to the filelen
- the length to truncate it tohandler
- the handler that will be called on completionBlocking version of FileSystem.truncate
Unlinks the link on the file system represented by the path link
, asynchronously.
link
- the linkhandler
- the handler that will be called on completionBlocking version of FileSystem.unlink
Creates the file, and writes the specified Buffer data
to the file represented by the path path
,
asynchronously.
path
- path to the filehandler
- the handler that will be called on completionBlocking version of FileSystem.writeFile