vertx / io.vertx.reactivex.core.file / AsyncFile

AsyncFile

open class AsyncFile : ReadStream<Buffer>, WriteStream<Buffer>

Represents a file on the file-system which can be read from, or written to asynchronously.

This class also implements io.vertx.reactivex.core.streams.ReadStream and io.vertx.reactivex.core.streams.WriteStream. This allows the data to be pumped to and from other streams, e.g. an io.vertx.reactivex.core.http.HttpClientRequest instance, using the io.vertx.reactivex.core.streams.Pump class

NOTE: This class has been automatically generated from the io.vertx.core.file.AsyncFile non RX-ified interface using Vert.x codegen.

Constructors

<init>

AsyncFile(delegate: AsyncFile)

Properties

__TYPE_ARG

static val __TYPE_ARG: TypeArg<AsyncFile>

Functions

close

open fun close(): Unit

Close the file. The actual close happens asynchronously.

open fun close(handler: Handler<AsyncResult<Void>>): Unit

Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

drainHandler

open fun drainHandler(handler: Handler<Void>): AsyncFile

end

open fun end(t: Buffer): Unit

Same as io.vertx.reactivex.core.file.AsyncFile#end but writes some data to the stream before ending.

open fun end(): Unit

Close the file, see io.vertx.reactivex.core.file.AsyncFile#close.

endHandler

open fun endHandler(endHandler: Handler<Void>): AsyncFile

equals

open fun equals(other: Any?): Boolean

exceptionHandler

open fun exceptionHandler(handler: Handler<Throwable>): AsyncFile

flush

open fun flush(): AsyncFile

Flush any writes made to this file to underlying persistent storage.

If the file was opened with flush set to true then calling this method will have no effect.

The actual flush will happen asynchronously.

open fun flush(handler: Handler<AsyncResult<Void>>): AsyncFile

Same as io.vertx.reactivex.core.file.AsyncFile#flush but the handler will be called when the flush is complete or if an error occurs

getDelegate

open fun getDelegate(): AsyncFile

handler

open fun handler(handler: Handler<Buffer>): AsyncFile

hashCode

open fun hashCode(): Int

newInstance

open static fun newInstance(arg: AsyncFile): AsyncFile

pause

open fun pause(): AsyncFile

read

open fun read(buffer: Buffer, offset: Int, position: Long, length: Int, handler: Handler<AsyncResult<Buffer>>): AsyncFile

Reads 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.

resume

open fun resume(): AsyncFile

rxClose

open fun rxClose(): Completable

Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

rxFlush

open fun rxFlush(): Completable

Same as io.vertx.reactivex.core.file.AsyncFile#flush but the handler will be called when the flush is complete or if an error occurs

rxRead

open fun rxRead(buffer: Buffer, offset: Int, position: Long, length: Int): Single<Buffer>

Reads 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.

rxWrite

open fun rxWrite(buffer: Buffer, position: Long): Completable

Write a io.vertx.reactivex.core.buffer.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.

setReadBufferSize

open fun setReadBufferSize(readBufferSize: Int): AsyncFile

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.

setReadPos

open fun setReadPos(readPos: Long): AsyncFile

Sets the position from which data will be read from when using the file as a io.vertx.reactivex.core.streams.ReadStream.

setWritePos

open fun setWritePos(writePos: Long): AsyncFile

Sets the position from which data will be written when using the file as a io.vertx.reactivex.core.streams.WriteStream.

setWriteQueueMaxSize

open fun setWriteQueueMaxSize(maxSize: Int): AsyncFile

toFlowable

open fun toFlowable(): Flowable<Buffer>

toObservable

open fun toObservable(): Observable<Buffer>

toString

open fun toString(): String

write

open fun write(data: Buffer): AsyncFileopen fun write(buffer: Buffer, position: Long, handler: Handler<AsyncResult<Void>>): AsyncFile

Write a io.vertx.reactivex.core.buffer.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.

writeQueueFull

open fun writeQueueFull(): Boolean

This will return true if there are more bytes in the write queue than the value set using io.vertx.reactivex.core.file.AsyncFile#setWriteQueueMaxSize