new AsyncFile(asyncFile)
An AsyncFile
represents a file on the file-system which can be
read from, or written to asynchronously. Methods also exist to get a
ReadStream
or a WriteStream
on the file. This
allows the data to be pumped to and from other streams. Instances of this
class are not thread-safe
These should not be created directly. Rather they are created internally by vert.x and provided to callback handlers and as return values from synchronous functions.
Parameters:
Name | Type | Description |
---|---|---|
asyncFile |
org.vertx.java.core.file.AsyncFile | the underlying java representation of this AsyncFile |
- Source:
Extends
Methods
-
close(handler)
-
Close the file asynchronously
Parameters:
Name Type Description handler
ResultHandler the handler to be called when the operation completes - Source:
-
dataHandler(handler)
-
Set a data handler. As data is read, the handler will be called with a Buffer containing the data read.
Parameters:
Name Type Description handler
BodyHandler the handler to call - Inherited From:
- Source:
-
drainHandler(handler)
-
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue has been reduced to maxSize/2. See
module:vertx/pump~Pump
for an example of this being used.Parameters:
Name Type Description handler
Handler the handler to call when the stream has been drained - Inherited From:
- Source:
-
endHandler(handler)
-
Set an end handler. Once the stream has ended, and there is no more data to be read, the handler will be called.
Parameters:
Name Type Description handler
Handler the handler to call - Inherited From:
- Source:
-
exceptionHandler(handler)
-
Set an exception handler.
Parameters:
Name Type Description handler
Handler the handler to call - Inherited From:
- Source:
-
exceptionHandler(handler)
-
Set an exception handler on the stream
Parameters:
Name Type Description handler
Handler the handler to call when an exception occurs - Inherited From:
- Source:
-
flush(handler)
-
Flush any writes made to this file to persistent storage.
Parameters:
Name Type Description handler
ResultHandler The handler to be called when the flush has completed - Source:
-
pause()
-
Pause the
ReadStream
. While the stream is paused, no data will be sent to the data Handler- Inherited From:
- Source:
-
read(buffer, offset, position, length, handler)
-
Read from the file asynchronously
Parameters:
Name Type Description buffer
Buffer The buffer to fill with the contents of the file offset
number The offset point in the Buffer from which to start writing position
number The position in the file from which to begin reading length
number the number of bytes to read handler
ResultHandler the handler to call when close() has been completed and will be provided the filled Buffer as a parameter - Source:
-
resume()
-
Resume reading. If the
ReadStream
has been paused, reading will recommence on it.- Inherited From:
- Source:
-
write(buffer, position, handler) → {module:vertx/file_system}
-
Write to the file asynchronously
Parameters:
Name Type Description buffer
Buffer | string the data to write position
number the byte position from which to start writing handler
ResultHandler the handler to call when the write has completed - Source:
Returns:
-
writeQueueFull()
-
This will return
true
if there are more bytes in the write queue than the value set usingwriteQueueMaxSize
- Inherited From:
- Source:
-
writeQueueMaxSize(size)
-
Set the maximum size of the write queue to
maxSize
. You will still be able to write to the stream even if there is more thanmaxSize
bytes in the write queue. This is used as an indicator by classes such asPump
to provide flow control.Parameters:
Name Type Description size
number the size of the write queue - Inherited From:
- Source: