org.vertx.java.core.file.impl

## Class DefaultAsyncFile

- java.lang.Object
- - org.vertx.java.core.file.impl.DefaultAsyncFile

All Implemented Interfaces:
  AsyncFile

    public class DefaultAsyncFile
    extends java.lang.Object
    implements AsyncFile

### Field Summary

### Fields inherited from interface org.vertx.java.core.file.AsyncFile

`BUFFER_SIZE`

### Method Summary

Methods
`void` `close()` Close the file.
`void` `close(AsyncResultHandler handler)` Close the file.
`void` `flush()` Flush any writes made to this file to underlying persistent storage.
`void` `flush(AsyncResultHandler handler)` Same as `AsyncFile.flush()` but the handler will be called when the flush is complete or if an error occurs
`ReadStream` `getReadStream()` Return a `ReadStream` instance operating on this `AsyncFile`.
`WriteStream` `getWriteStream()` Return a `WriteStream` instance operating on this `AsyncFile`.
`void` `read(Buffer buffer, int offset, int position, int length, AsyncResultHandler<Buffer> handler)` Reads `length` bytes of data from the file at position `position` in the file, asynchronously.
`void` `write(Buffer buffer, int position, AsyncResultHandler<java.lang.Void> handler)` Write a `Buffer` to the file at position `position` in the file, asynchronously.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### close

    public void close()

Description copied from interface: `AsyncFile`
Close the file. The actual close happens asynchronously.

Specified by:
  `close` in interface `AsyncFile`

#### close

    public void close(AsyncResultHandler handler)

Description copied from interface: `AsyncFile`
Close the file. The actual close happens asynchronously. The handler will be called when the close is complete, or an error occurs.

Specified by:
  `close` in interface `AsyncFile`

#### write

    public void write(Buffer buffer,
             int position,
             AsyncResultHandler<java.lang.Void> handler)

Description copied from interface: `AsyncFile`
Write a `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.

Specified by:
  `write` in interface `AsyncFile`

#### read

    public void read(Buffer buffer,
            int offset,
            int position,
            int length,
            AsyncResultHandler<Buffer> handler)

Description copied from interface: `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`.

The index `position + length` must lie within the confines of the file.

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.

Specified by:
  `read` in interface `AsyncFile`

#### getWriteStream

    public WriteStream getWriteStream()

Description copied from interface: `AsyncFile`
Return a `WriteStream` instance operating on this `AsyncFile`.

Specified by:
  `getWriteStream` in interface `AsyncFile`

#### getReadStream

    public ReadStream getReadStream()

Description copied from interface: `AsyncFile`
Return a `ReadStream` instance operating on this `AsyncFile`.

Specified by:
  `getReadStream` in interface `AsyncFile`

#### flush

    public void flush()

Description copied from interface: `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.

Specified by:
  `flush` in interface `AsyncFile`

#### flush

    public void flush(AsyncResultHandler handler)

Description copied from interface: `AsyncFile`
Same as `AsyncFile.flush()` but the handler will be called when the flush is complete or if an error occurs

Specified by:
  `flush` in interface `AsyncFile`