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 handlerResultHandler 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 handlerBodyHandler 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~Pumpfor an example of this being used.Parameters:
Name Type Description handlerHandler 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 handlerHandler the handler to call - Inherited From:
- Source:
-
exceptionHandler(handler)
-
Set an exception handler.
Parameters:
Name Type Description handlerHandler the handler to call - Inherited From:
- Source:
-
exceptionHandler(handler)
-
Set an exception handler on the stream
Parameters:
Name Type Description handlerHandler 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 handlerResultHandler 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 bufferBuffer The buffer to fill with the contents of the file offsetnumber The offset point in the Buffer from which to start writing positionnumber The position in the file from which to begin reading lengthnumber the number of bytes to read handlerResultHandler 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
ReadStreamhas 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 bufferBuffer | string the data to write positionnumber the byte position from which to start writing handlerResultHandler the handler to call when the write has completed - Source:
Returns:
-
writeQueueFull()
-
This will return
trueif 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 thanmaxSizebytes in the write queue. This is used as an indicator by classes such asPumpto provide flow control.Parameters:
Name Type Description sizenumber the size of the write queue - Inherited From:
- Source: