Represents a file on the file-system which can be read from, or written to asynchronously.
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
Anything
no subtypes hierarchy
Initializer |
AsyncFile(AsyncFile unknown) |
Inherited Attributes |
Attributes inherited from: Object hash , string |
Methods | |
close | shared default void close() Close the file. The actual close happens asynchronously. |
close | shared default void close(Anything(Throwable?) handler) Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs. Parameters:
|
drainHandler | shared actual default AsyncFile drainHandler(Anything()? 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 Pump for an example of this being used. Refines WriteStream.drainHandler |
end | shared actual default void end() Close the file, see close. Refines WriteStream.end |
end | shared actual default void end(Buffer t) Same as end but writes some data to the stream before ending. Refines WriteStream.end |
endHandler | shared actual default AsyncFile endHandler(Anything()? endHandler) Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called. Refines ReadStream.endHandler |
exceptionHandler | shared actual default AsyncFile exceptionHandler(Anything(Throwable)? handler) Set an exception handler. Refines StreamBase.exceptionHandler |
flush | shared default AsyncFile flush() Flush any writes made to this file to underlying persistent storage.
If the file was opened with The actual flush will happen asynchronously. |
flush | shared default AsyncFile flush(Anything(Throwable?) handler) Same as flush but the handler will be called when the flush is complete or if an error occurs |
handler | shared actual default AsyncFile handler(Anything(Buffer)? handler) Set a data handler. As data is read, the handler will be called with the data. Refines ReadStream.handler |
pause | shared actual default AsyncFile pause() Pause the Refines ReadStream.pause |
read | shared default AsyncFile read(Buffer buffer, Integer offset, Integer position, Integer length, Anything(Throwable|Buffer) handler) Reads
The read data will be written into the specified 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. Parameters:
|
resume | shared actual default AsyncFile resume() Resume reading. If the Refines ReadStream.resume |
setReadBufferSize | shared default AsyncFile setReadBufferSize(Integer readBufferSize) Sets the buffer size that will be used to read the data from the file. Changing this value will impact how much the data will be read at a time from the file system. Parameters:
|
setReadPos | shared default AsyncFile setReadPos(Integer readPos) Sets the position from which data will be read from when using the file as a ReadStream. Parameters:
|
setWritePos | shared default AsyncFile setWritePos(Integer writePos) Sets the position from which data will be written when using the file as a WriteStream. Parameters:
|
setWriteQueueMaxSize | shared actual default AsyncFile setWriteQueueMaxSize(Integer maxSize) Set the maximum size of the write queue to Refines WriteStream.setWriteQueueMaxSize |
write | shared actual default AsyncFile write(Buffer data) Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the writeQueueFull method before writing. This is done automatically if using a Pump. Refines WriteStream.write |
write | shared default AsyncFile write(Buffer buffer, Integer position, Anything(Throwable?) handler) Write a Buffer to the file at position
If 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. Parameters:
|
writeQueueFull | shared actual default Boolean writeQueueFull() This will return Refines WriteStream.writeQueueFull |
Inherited Methods |
Methods inherited from: Object equals |
Methods inherited from: ReadStream<T> |
Methods inherited from: StreamBase |
Methods inherited from: WriteStream<T> |