vertx-lang-scala-docs_2.12 3.6.0 API < Back
 

# Packages

-  package root
  Definition Classes
    root
-  package io
  Definition Classes
    root
-  package vertx
  Definition Classes
    io
-  package scala
  Definition Classes
    vertx
-  package core
  Definition Classes
    scala
-  package file
  Definition Classes
    core
- AsyncFile
- CopyOptions
- FileProps
- FileSystem
- FileSystemOptions
- FileSystemProps
- OpenOptions

c

io.vertx.scala.core.file

# AsyncFile 

###
Companion object AsyncFile

#### class AsyncFile extends ReadStream[Buffer] with WriteStream[Buffer]

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

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

Linear Supertypes
WriteStream[Buffer], ReadStream[Buffer], StreamBase, AnyRef, Any
 
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. AsyncFile
2. WriteStream
3. ReadStream
4. StreamBase
5. AnyRef
6. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Instance Constructors

1.  new AsyncFile(_asJava: AnyRef)

### Value Members

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##(): Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
5.  def asJava: AnyRef
   Definition Classes
     AsyncFile → WriteStream → ReadStream → StreamBase
6.  def clone(): AnyRef
   Attributes
     protected[java.lang]
   Definition Classes
     AnyRef
   Annotations
     @native() @throws( ... )
7.  def close(handler: Handler[AsyncResult[Unit]]): Unit

   Close the file.

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

8.  def close(): Unit

   Close the file.

   Close the file. The actual close happens asynchronously.

9.  def closeFuture(): scala.concurrent.Future[Unit]

   Like close but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

10.  def drainHandler(handler: Handler[Unit]): AsyncFile

    Set a drain handler on the stream.

    Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See io.vertx.scala.core.streams.Pump for an example of this being used.

    The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to `maxSize / 2`. * @param handler the handler

    returns

      a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → WriteStream
11.  def end(): Unit

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

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

    Definition Classes
      AsyncFile → WriteStream
12.  def end(t: Buffer): Unit

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

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

    Definition Classes
      AsyncFile → WriteStream
13.  def endHandler(endHandler: Handler[Unit]): AsyncFile

    Set an end handler.

    Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called. * @return a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → ReadStream
14.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
15.  def equals(arg0: Any): Boolean
    Definition Classes
      AnyRef → Any
16.  def exceptionHandler(handler: Handler[Throwable]): AsyncFile

    Set an exception handler on the write stream.

    Set an exception handler on the write stream. * @param handler the exception handler

    returns

      a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → WriteStream → ReadStream → StreamBase
17.  def fetch(amount: Long): AsyncFile

    Fetch the specified `amount` of elements.

    Fetch the specified `amount` of elements. If the `ReadStream` has been paused, reading will recommence with the specified `amount` of items, otherwise the specified `amount` will be added to the current stream demand. * @return a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → ReadStream
18.  def finalize(): Unit
    Attributes
      protected[java.lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )
19.  def flush(handler: Handler[AsyncResult[Unit]]): AsyncFile

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

20.  def flush(): AsyncFile

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

    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. * @return a reference to this, so the API can be used fluently

21.  def flushFuture(): scala.concurrent.Future[Unit]

    Like flush but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

22.  final def getClass(): Class[_]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
23.  def handler(handler: Handler[Buffer]): AsyncFile

    Set a data handler.

    Set a data handler. As data is read, the handler will be called with the data. * @return a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → ReadStream
24.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
25.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
26.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
27.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
28.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
29.  def pause(): AsyncFile

    Pause the `ReadStream`, it sets the buffer in `fetch` mode and clears the actual demand.

    Pause the `ReadStream`, it sets the buffer in `fetch` mode and clears the actual demand.

    While it's paused, no data will be sent to the data `handler`. * @return a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → ReadStream
30.  def 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.

    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. * @param buffer the buffer to read into

    offset

      the offset into the buffer where the data will be read

    position

      the position in the file where to start reading

    length

      the number of bytes to read

    handler

      the handler to call when the write is complete

    returns

      a reference to this, so the API can be used fluently

31.  def readFuture(buffer: Buffer, offset: Int, position: Long, length: Int): scala.concurrent.Future[Buffer]

    Like read but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

32.  def resume(): AsyncFile

    Resume reading, and sets the buffer in `flowing` mode.

    Resume reading, and sets the buffer in `flowing` mode.

    If the `ReadStream` has been paused, reading will recommence on it. * @return a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → ReadStream
33.  def setReadBufferSize(readBufferSize: Int): AsyncFile

    Sets the buffer size that will be used to read the data from the file.

    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. * @param readBufferSize the buffer size

    returns

      a reference to this, so the API can be used fluently

34.  def setReadPos(readPos: Long): AsyncFile

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

    Sets the position from which data will be read from when using the file as a io.vertx.scala.core.streams.ReadStream. * @param readPos the position in the file

    returns

      a reference to this, so the API can be used fluently

35.  def setWritePos(writePos: Long): AsyncFile

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

    Sets the position from which data will be written when using the file as a io.vertx.scala.core.streams.WriteStream. * @param writePos the position in the file

    returns

      a reference to this, so the API can be used fluently

36.  def setWriteQueueMaxSize(maxSize: Int): AsyncFile

    Set the maximum size of the write queue to `maxSize`.

    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 than `maxSize` items in the write queue. This is used as an indicator by classes such as `Pump` to provide flow control.

    The value is defined by the implementation of the stream, e.g in bytes for a io.vertx.scala.core.net.NetSocket, the number of io.vertx.scala.core.eventbus.Message for a io.vertx.scala.core.eventbus.MessageProducer, etc... * @param maxSize the max size of the write stream

    returns

      a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → WriteStream
37.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
38.  def toString(): String
    Definition Classes
      AnyRef → Any
39.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
40.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
41.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @native() @throws( ... )
42.  def write(buffer: Buffer, position: Long, handler: Handler[AsyncResult[Unit]]): AsyncFile

    Write a io.vertx.scala.core.buffer.Buffer to the file at position `position` in the file, asynchronously.

    Write a io.vertx.scala.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. * @param buffer the buffer to write

    position

      the position in the file to write it at

    handler

      the handler to call when the write is complete

    returns

      a reference to this, so the API can be used fluently

43.  def write(data: Buffer): AsyncFile

    Write some data to the stream.

    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 io.vertx.scala.core.streams.WriteStream#writeQueueFull method before writing. This is done automatically if using a io.vertx.scala.core.streams.Pump. * @param data the data to write

    returns

      a reference to this, so the API can be used fluently

    Definition Classes
      AsyncFile → WriteStream
44.  def writeFuture(buffer: Buffer, position: Long): scala.concurrent.Future[Unit]

    Like write but returns a scala.concurrent.Future instead of taking an AsyncResultHandler.

45.  def writeQueueFull(): Boolean

    This will return `true` if there are more bytes in the write queue than the value set using io.vertx.scala.core.file.AsyncFile#setWriteQueueMaxSize * @return true if write queue is full

    This will return `true` if there are more bytes in the write queue than the value set using io.vertx.scala.core.file.AsyncFile#setWriteQueueMaxSize * @return true if write queue is full

    Definition Classes
      AsyncFile → WriteStream

### Inherited from WriteStream[Buffer]

### Inherited from ReadStream[Buffer]

### Inherited from StreamBase

### Inherited from AnyRef

### Inherited from Any

### Ungrouped