FileSystem
object provides many operations for manipulating the file system.See: Description
Interface | Description |
---|---|
AsyncFile |
Represents a file on the file-system which can be read from, or written to asynchronously.
|
FileProps |
Represents properties of a file on the file system.
|
FileSystem |
Contains a broad set of operations for manipulating files on the file system.
|
FileSystemProps |
Represents properties of the file system.
|
Class | Description |
---|---|
OpenOptions |
Describes how an
AsyncFile should be opened. |
Exception | Description |
---|---|
FileSystemException |
Exception thrown by the FileSystem class
|
FileSystem
object provides many operations for manipulating the file system.
There is one file system object per Vert.x instance, and you obtain it with Vertx.fileSystem()
.
A blocking and a 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.
Here's an example of asynchronously copying a file:
[source,$lang]
----
FileSystemExamples.example1(io.vertx.core.Vertx)
----
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 from an event loop, so as not to break the Golden Rule.
Here's the copy using the blocking API:
[source,$lang]
----
FileSystemExamples.example2(io.vertx.core.Vertx)
----
Many operations exist to copy, move, truncate, chmod and many other file operations.
We won't list them all here, please consult the API docs
for the full list.
=== Asynchronous files
Vert.x provides an asynchronous file abstraction that allows you to manipulate a file on the file system
You open an AsyncFile
as follows:
[source,$lang]
----
FileSystemExamples.example3(io.vertx.core.file.FileSystem)
----
TODOCopyright © 2015. All Rights Reserved.