org.vertx.java.core.file

## Interface AsyncFile

All Known Implementing Classes:
  DefaultAsyncFile

    public interface AsyncFile

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

Methods also exist to get a `ReadStream` or a `WriteStream` on the file. This allows the data to be pumped to and from other streams, e.g. an `HttpClientRequest` instance, using the `Pump` class

Instances of this class are not thread-safe

### Field Summary

Fields
`static int` `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 `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.

### Field Detail

#### BUFFER_SIZE

    static final int BUFFER_SIZE

See Also:
  Constant Field Values

### Method Detail

#### close

    void close()

Close the file. The actual close happens asynchronously.

#### close

    void close(AsyncResultHandler handler)

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

#### write

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

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.

#### read

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

#### getWriteStream

    WriteStream getWriteStream()

Return a `WriteStream` instance operating on this `AsyncFile`.

#### getReadStream

    ReadStream getReadStream()

Return a `ReadStream` instance operating on this `AsyncFile`.

#### flush

    void flush()

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.

#### flush

    void flush(AsyncResultHandler handler)

Same as `flush()` but the handler will be called when the flush is complete or if an error occurs

Parameters:
  `handler` -