public interface FileSystem
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.
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,
CopyOptions options,
Handler<AsyncResult<Void>> handler)
Copy a file from the path
from to path to , asynchronously. |
FileSystem |
copy(String from,
String to,
Handler<AsyncResult<Void>> handler)
Copy a file from the path
from to path to , asynchronously. |
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. |
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 |
createTempDirectory(String prefix,
Handler<AsyncResult<String>> handler)
Creates a new directory in the default temporary-file directory, using the given
prefix to generate its name, asynchronously.
|
FileSystem |
createTempDirectory(String prefix,
String perms,
Handler<AsyncResult<String>> handler)
Creates a new directory in the default temporary-file directory, using the given
prefix to generate its name, asynchronously.
|
FileSystem |
createTempDirectory(String dir,
String prefix,
String perms,
Handler<AsyncResult<String>> handler)
Creates a new directory in the directory provided by the path
path , using the given
prefix to generate its name, asynchronously. |
String |
createTempDirectoryBlocking(String prefix)
Blocking version of
createTempDirectory(String, Handler) |
String |
createTempDirectoryBlocking(String prefix,
String perms)
Blocking version of
createTempDirectory(String, String, Handler) |
String |
createTempDirectoryBlocking(String dir,
String prefix,
String perms)
Blocking version of
createTempDirectory(String, String, String, Handler) |
FileSystem |
createTempFile(String prefix,
String suffix,
Handler<AsyncResult<String>> handler)
Creates a new file in the default temporary-file directory, using the given
prefix and suffix to generate its name, asynchronously.
|
FileSystem |
createTempFile(String prefix,
String suffix,
String perms,
Handler<AsyncResult<String>> handler)
Creates a new file in the directory provided by the path
dir , using the given
prefix and suffix to generate its name, asynchronously. |
FileSystem |
createTempFile(String dir,
String prefix,
String suffix,
String perms,
Handler<AsyncResult<String>> handler)
Creates a new file in the directory provided by the path
dir , using the given
prefix and suffix to generate its name, asynchronously. |
String |
createTempFileBlocking(String prefix,
String suffix)
Blocking version of
createTempFile(String, String, Handler) |
String |
createTempFileBlocking(String prefix,
String suffix,
String perms)
Blocking version of
createTempFile(String, String, String, Handler) |
String |
createTempFileBlocking(String dir,
String prefix,
String suffix,
String perms)
Blocking version of
createTempFile(String, String, 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. |
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. |
FileSystem |
mkdir(String path,
String perms,
Handler<AsyncResult<Void>> handler)
Create the directory represented by
path , asynchronously. |
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 and any non existent parents, asynchronously. |
FileSystem |
mkdirs(String path,
String perms,
Handler<AsyncResult<Void>> handler)
Create the directory represented by
path and any non existent parents, asynchronously. |
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,
CopyOptions options,
Handler<AsyncResult<Void>> handler)
Move a file from the path
from to path to , asynchronously. |
FileSystem |
move(String from,
String to,
Handler<AsyncResult<Void>> handler)
Move a file from the path
from to path to , asynchronously. |
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. |
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. |
FileSystem |
readDir(String path,
String filter,
Handler<AsyncResult<List<String>>> handler)
Read the contents of the directory specified by
path , asynchronously. |
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. |
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. |
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)
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 completionFileSystem copy(String from, String to, CopyOptions options, Handler<AsyncResult<Void>> handler)
from
to path to
, asynchronously.from
- the path to copy fromto
- the path to copy tooptions
- options describing how the file should be copiedhandler
- the handler that will be called on completionFileSystem copyBlocking(String from, String to)
copy(String, String, Handler)
FileSystem copyRecursive(String from, String to, boolean recursive, Handler<AsyncResult<Void>> handler)
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 torecursive
- handler
- the handler that will be called on completionFileSystem copyRecursiveBlocking(String from, String to, boolean recursive)
copyRecursive(String, String, boolean, Handler)
FileSystem move(String from, String to, Handler<AsyncResult<Void>> handler)
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 completionFileSystem move(String from, String to, CopyOptions options, Handler<AsyncResult<Void>> handler)
from
to path to
, asynchronously.from
- the path to copy fromto
- the path to copy tooptions
- options describing how the file should be copiedhandler
- the handler that will be called on completionFileSystem moveBlocking(String from, String to)
move(String, String, Handler)
FileSystem truncate(String path, long len, Handler<AsyncResult<Void>> handler)
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 completionFileSystem truncateBlocking(String path, long len)
truncate(String, long, Handler)
FileSystem chmod(String path, String perms, Handler<AsyncResult<Void>> handler)
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 completionFileSystem chmodBlocking(String path, String perms)
chmod(String, String, Handler)
FileSystem chmodRecursive(String path, String perms, String dirPerms, Handler<AsyncResult<Void>> handler)
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 completionFileSystem chmodRecursiveBlocking(String path, String perms, String dirPerms)
chmodRecursive(String, String, String, Handler)
FileSystem chown(String path, String user, String group, Handler<AsyncResult<Void>> handler)
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 completionFileSystem chownBlocking(String path, String user, String group)
chown(String, String, String, Handler)
FileSystem props(String path, Handler<AsyncResult<FileProps>> handler)
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 completionFileProps propsBlocking(String path)
props(String, Handler)
FileSystem lprops(String path, Handler<AsyncResult<FileProps>> handler)
path
, asynchronously.
The link will not be followed.
path
- the path to the filehandler
- the handler that will be called on completionFileProps lpropsBlocking(String path)
lprops(String, Handler)
FileSystem link(String link, String existing, Handler<AsyncResult<Void>> handler)
link
to existing
, asynchronously.link
- the linkexisting
- the link destinationhandler
- the handler that will be called on completionFileSystem linkBlocking(String link, String existing)
link(String, String, Handler)
FileSystem symlink(String link, String existing, Handler<AsyncResult<Void>> handler)
link
to existing
, asynchronously.link
- the linkexisting
- the link destinationhandler
- the handler that will be called on completionFileSystem symlinkBlocking(String link, String existing)
link(String, String, Handler)
FileSystem unlink(String link, Handler<AsyncResult<Void>> handler)
link
, asynchronously.link
- the linkhandler
- the handler that will be called on completionFileSystem unlinkBlocking(String link)
unlink(String, Handler)
FileSystem readSymlink(String link, Handler<AsyncResult<String>> handler)
link
points to, asynchronously.link
- the linkhandler
- the handler that will be called on completionString readSymlinkBlocking(String link)
readSymlink(String, Handler)
FileSystem delete(String path, Handler<AsyncResult<Void>> handler)
path
, asynchronously.path
- path to the filehandler
- the handler that will be called on completionFileSystem deleteBlocking(String path)
delete(String, Handler)
FileSystem deleteRecursive(String path, boolean recursive, Handler<AsyncResult<Void>> handler)
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 completionFileSystem deleteRecursiveBlocking(String path, boolean recursive)
deleteRecursive(String, boolean, Handler)
FileSystem mkdir(String path, Handler<AsyncResult<Void>> handler)
path
, asynchronously.
The operation will fail if the directory already exists.
path
- path to the filehandler
- the handler that will be called on completionFileSystem mkdirBlocking(String path)
mkdir(String, Handler)
FileSystem mkdir(String path, String perms, Handler<AsyncResult<Void>> handler)
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 completionFileSystem mkdirBlocking(String path, String perms)
mkdir(String, String, Handler)
FileSystem mkdirs(String path, Handler<AsyncResult<Void>> handler)
path
and any non existent parents, asynchronously.
The operation will fail if the path
already exists but is not a directory.
path
- path to the filehandler
- the handler that will be called on completionFileSystem mkdirsBlocking(String path)
mkdirs(String, Handler)
FileSystem mkdirs(String path, String perms, Handler<AsyncResult<Void>> handler)
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 path
already exists but is not a directory.
path
- path to the fileperms
- the permissions stringhandler
- the handler that will be called on completionFileSystem mkdirsBlocking(String path, String perms)
mkdirs(String, String, Handler)
FileSystem readDir(String path, Handler<AsyncResult<List<String>>> handler)
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 completionList<String> readDirBlocking(String path)
readDir(String, Handler)
FileSystem readDir(String path, String filter, Handler<AsyncResult<List<String>>> handler)
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 completionList<String> readDirBlocking(String path, String filter)
readDir(String, String, Handler)
FileSystem readFile(String path, Handler<AsyncResult<Buffer>> handler)
path
as a Buffer
, asynchronously.
Do not use 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 completionBuffer readFileBlocking(String path)
readFile(String, Handler)
FileSystem writeFile(String path, Buffer data, Handler<AsyncResult<Void>> handler)
Buffer data
to the file represented by the path path
,
asynchronously.path
- path to the filehandler
- the handler that will be called on completionFileSystem writeFileBlocking(String path, Buffer data)
writeFile(String, Buffer, Handler)
FileSystem open(String path, OpenOptions options, Handler<AsyncResult<AsyncFile>> handler)
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 openedAsyncFile openBlocking(String path, OpenOptions options)
open(String, io.vertx.core.file.OpenOptions, Handler)
FileSystem createFile(String path, Handler<AsyncResult<Void>> handler)
path
, asynchronously.path
- path to the filehandler
- the handler that will be called on completionFileSystem createFileBlocking(String path)
createFile(String, Handler)
FileSystem createFile(String path, String perms, Handler<AsyncResult<Void>> handler)
path
and permissions perms
, asynchronously.path
- path to the fileperms
- the permissions stringhandler
- the handler that will be called on completionFileSystem createFileBlocking(String path, String perms)
createFile(String, String, Handler)
FileSystem exists(String path, Handler<AsyncResult<Boolean>> handler)
path
exists, asynchronously.path
- path to the filehandler
- the handler that will be called on completionboolean existsBlocking(String path)
exists(String, Handler)
FileSystem fsProps(String path, Handler<AsyncResult<FileSystemProps>> handler)
path
, asynchronously.path
- path to anywhere on the filesystemhandler
- the handler that will be called on completionFileSystemProps fsPropsBlocking(String path)
fsProps(String, Handler)
FileSystem createTempDirectory(String prefix, Handler<AsyncResult<String>> handler)
As with the File.createTempFile
methods, this method is only
part of a temporary-file facility.A shutdown-hook
,
or the File.deleteOnExit()
mechanism may be used to delete the directory automatically.
prefix
- the prefix string to be used in generating the directory's name;
may be null
handler
- the handler that will be called on completionString createTempDirectoryBlocking(String prefix)
createTempDirectory(String, Handler)
FileSystem createTempDirectory(String prefix, String perms, Handler<AsyncResult<String>> handler)
The new directory will be created with permissions as specified by perms
.
As with the File.createTempFile
methods, this method is only
part of a temporary-file facility.A shutdown-hook
,
or the File.deleteOnExit()
mechanism may be used to delete the directory automatically.
prefix
- the prefix string to be used in generating the directory's name;
may be null
perms
- the permissions stringhandler
- the handler that will be called on completionString createTempDirectoryBlocking(String prefix, String perms)
createTempDirectory(String, String, Handler)
FileSystem createTempDirectory(String dir, String prefix, String perms, Handler<AsyncResult<String>> handler)
path
, using the given
prefix to generate its name, asynchronously.
The new directory will be created with permissions as specified by perms
.
As with the File.createTempFile
methods, this method is only
part of a temporary-file facility.A shutdown-hook
,
or the File.deleteOnExit()
mechanism may be used to delete the directory automatically.
dir
- the path to directory in which to create the directoryprefix
- the prefix string to be used in generating the directory's name;
may be null
perms
- the permissions stringhandler
- the handler that will be called on completionString createTempDirectoryBlocking(String dir, String prefix, String perms)
createTempDirectory(String, String, String, Handler)
FileSystem createTempFile(String prefix, String suffix, Handler<AsyncResult<String>> handler)
As with the File.createTempFile
methods, this method is only
part of a temporary-file facility.A shutdown-hook
,
or the File.deleteOnExit()
mechanism may be used to delete the directory automatically.
prefix
- the prefix string to be used in generating the directory's name;
may be null
suffix
- the suffix string to be used in generating the file's name;
may be null
, in which case ".tmp
" is usedhandler
- the handler that will be called on completionString createTempFileBlocking(String prefix, String suffix)
createTempFile(String, String, Handler)
FileSystem createTempFile(String prefix, String suffix, String perms, Handler<AsyncResult<String>> handler)
dir
, using the given
prefix and suffix to generate its name, asynchronously.
As with the File.createTempFile
methods, this method is only
part of a temporary-file facility.A shutdown-hook
,
or the File.deleteOnExit()
mechanism may be used to delete the directory automatically.
prefix
- the prefix string to be used in generating the directory's name;
may be null
suffix
- the suffix string to be used in generating the file's name;
may be null
, in which case ".tmp
" is usedhandler
- the handler that will be called on completionString createTempFileBlocking(String prefix, String suffix, String perms)
createTempFile(String, String, String, Handler)
FileSystem createTempFile(String dir, String prefix, String suffix, String perms, Handler<AsyncResult<String>> handler)
dir
, using the given
prefix and suffix to generate its name, asynchronously.
The new directory will be created with permissions as specified by perms
.
As with the File.createTempFile
methods, this method is only
part of a temporary-file facility.A shutdown-hook
,
or the File.deleteOnExit()
mechanism may be used to delete the directory automatically.
dir
- the path to directory in which to create the directoryprefix
- the prefix string to be used in generating the directory's name;
may be null
suffix
- the suffix string to be used in generating the file's name;
may be null
, in which case ".tmp
" is usedperms
- the permissions stringhandler
- the handler that will be called on completionCopyright © 2023 Eclipse. All rights reserved.