org.apache.ignite.internal.processors.cache.persistence.file

## Interface FileIO

All Superinterfaces:
  AutoCloseable

All Known Implementing Classes:
  AsyncFileIO, FileIODecorator, RandomAccessFileIO, UnzipFileIO

    public interface FileIO
    extends AutoCloseable

Interface to perform file I/O operations.

### Method Summary

All Methods Instance Methods Abstract Methods
`void` `clear()` Truncates current file to zero length and resets current file position to zero.
`void` `close()` Closes current file.
`void` `force()` Forces any updates of this file to be written to the storage device that contains it.
`MappedByteBuffer` `map(int maxWalSegmentSize)`
`long` `position()` Returns current file position.
`void` `position(long newPosition)` Sets new current file position.
`int` `read(byte[] buf, int off, int len)` Reads a up to `length` bytes from this file into the `buffer`.
`int` `read(ByteBuffer destBuf)` Reads a sequence of bytes from this file into the `destinationBuffer`.
`int` `read(ByteBuffer destBuf, long position)` Reads a sequence of bytes from this file into the `destinationBuffer` starting from specified file `position`.
`long` `size()` Returns current file size in bytes.
`void` `write(byte[] buf, int off, int len)` Writes `length` bytes from the `buffer` starting at offset `off` to this file.
`int` `write(ByteBuffer srcBuf)` Writes a sequence of bytes to this file from the `sourceBuffer`.
`int` `write(ByteBuffer srcBuf, long position)` Writes a sequence of bytes to this file from the `sourceBuffer` starting from specified file `position`

### Method Detail

#### position

    long position()
           throws IOException

Returns current file position.

Returns:
  Current file position, a non-negative integer counting the number of bytes from the beginning of the file to the current position.
Throws:
  `IOException` - If some I/O error occurs.

#### position

    void position(long newPosition)
           throws IOException

Sets new current file position.

Parameters:
  `newPosition` - The new position, a non-negative integer counting the number of bytes from the beginning of the file.
Throws:
  `IOException` - If some I/O error occurs.

#### read

    int read(ByteBuffer destBuf)
      throws IOException

Reads a sequence of bytes from this file into the `destinationBuffer`.

Parameters:
  `destBuf` - Destination byte buffer.
Returns:
  Number of read bytes, or `-1` if the given position is greater than or equal to the file's current size
Throws:
  `IOException` - If some I/O error occurs.

#### read

    int read(ByteBuffer destBuf,
             long position)
      throws IOException

Reads a sequence of bytes from this file into the `destinationBuffer` starting from specified file `position`.

Parameters:
  `destBuf` - Destination byte buffer.
  `position` - Starting position of file.
Returns:
  Number of read bytes, possibly zero, or `-1` if the given position is greater than or equal to the file's current size
Throws:
  `IOException` - If some I/O error occurs.

#### read

    int read(byte[] buf,
             int off,
             int len)
      throws IOException

Reads a up to `length` bytes from this file into the `buffer`.

Parameters:
  `buf` - Destination byte array.
  `off` - The start offset in array `b` at which the data is written.
  `len` - Maximum number of bytes read.
Returns:
  Number of read bytes.
Throws:
  `IOException` - If some I/O error occurs.

#### write

    int write(ByteBuffer srcBuf)
       throws IOException

Writes a sequence of bytes to this file from the `sourceBuffer`.

Parameters:
  `srcBuf` - Source buffer.
Returns:
  Number of written bytes.
Throws:
  `IOException` - If some I/O error occurs.

#### write

    int write(ByteBuffer srcBuf,
              long position)
       throws IOException

Writes a sequence of bytes to this file from the `sourceBuffer` starting from specified file `position`

Parameters:
  `srcBuf` - Source buffer.
  `position` - Starting file position.
Returns:
  Number of written bytes.
Throws:
  `IOException` - If some I/O error occurs.

#### write

    void write(byte[] buf,
               int off,
               int len)
        throws IOException

Writes `length` bytes from the `buffer` starting at offset `off` to this file.

Parameters:
  `buf` - Source byte array.
  `off` - Start offset in the `buffer`.
  `len` - Number of bytes to write.
Throws:
  `IOException` - If some I/O error occurs.

#### map

    MappedByteBuffer map(int maxWalSegmentSize)
                  throws IOException

Throws:
  `IOException`

#### force

    void force()
        throws IOException

Forces any updates of this file to be written to the storage device that contains it.

Throws:
  `IOException` - If some I/O error occurs.

#### size

    long size()
       throws IOException

Returns current file size in bytes.

Returns:
  File size.
Throws:
  `IOException` - If some I/O error occurs.

#### clear

    void clear()
        throws IOException

Truncates current file to zero length and resets current file position to zero.

Throws:
  `IOException` - If some I/O error occurs.

#### close

    void close()
        throws IOException

Closes current file.

Specified by:
  `close` in interface `AutoCloseable`
Throws:
  `IOException` - If some I/O error occurs.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.5.0
Release Date | : May 23 2018