public interface AsyncFile extends ReadStream<AsyncFile>, WriteStream<AsyncFile>
This class also implements ReadStream and
WriteStream. This allows the data to be pumped to and from
other streams, e.g. an HttpClientRequest instance,
using the Pump class
Instances of AsyncFile are not thread-safe
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the file.
|
void |
close(Handler<AsyncResult<java.lang.Void>> handler)
Close the file.
|
AsyncFile |
flush()
Flush any writes made to this file to underlying persistent storage.
|
AsyncFile |
flush(Handler<AsyncResult<java.lang.Void>> handler)
Same as
flush() but the handler will be called when the flush is complete or if an error occurs |
AsyncFile |
read(Buffer buffer,
int offset,
long position,
int length,
Handler<AsyncResult<Buffer>> handler)
Reads
length bytes of data from the file at position position in the file, asynchronously. |
AsyncFile |
write(Buffer buffer,
long position,
Handler<AsyncResult<java.lang.Void>> handler)
Write a
Buffer to the file at position position in the file, asynchronously. |
endHandlerdataHandler, pause, resumeexceptionHandlerwritedrainHandler, setWriteQueueMaxSize, writeQueueFullvoid close()
void close(Handler<AsyncResult<java.lang.Void>> handler)
AsyncFile write(Buffer buffer, long position, Handler<AsyncResult<java.lang.Void>> handler)
Buffer to the file at position position in the file, asynchronously.
If position lies outside of the current size
of the file, the file will be enlarged to encompass it.When multiple writes are invoked on the same file there are no guarantees as to order in which those writes actually occur.
The handler will be called when the write is complete, or if an error occurs.
AsyncFile read(Buffer buffer, int offset, long position, int length, Handler<AsyncResult<Buffer>> handler)
length bytes of data from the file at position position in the file, asynchronously.
The read data will be written into the specified Buffer buffer at position offset.If data is read past the end of the file then zero bytes will be read.
When multiple reads are invoked on the same file there are no guarantees as to order in which those reads actually occur.
The handler will be called when the close is complete, or if an error occurs.
AsyncFile flush()
If the file was opened with flush set to true then calling this method will have no effect.
The actual flush will happen asynchronously.
AsyncFile flush(Handler<AsyncResult<java.lang.Void>> handler)
flush() but the handler will be called when the flush is complete or if an error occurs