org.apache.poi.poifs.nio

## Class FileBackedDataSource

- java.lang.Object
- - org.apache.poi.poifs.nio.DataSource
  - - org.apache.poi.poifs.nio.FileBackedDataSource

-     public class FileBackedDataSource
      extends DataSource

  A POIFS `DataSource` backed by a File

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileBackedDataSource(java.io.File file)`
    `FileBackedDataSource(java.io.File file, boolean readOnly)`
    `FileBackedDataSource(java.nio.channels.FileChannel channel, boolean readOnly)`
    `FileBackedDataSource(java.io.RandomAccessFile srcFile, boolean readOnly)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the underlying stream
    `void` | `copyTo(java.io.OutputStream stream)` Copies the contents to the specified OutputStream
    `java.nio.channels.FileChannel` | `getChannel()`
    `boolean` | `isWriteable()`
    `java.nio.ByteBuffer` | `read(int length, long position)`
    `long` | `size()`
    `void` | `write(java.nio.ByteBuffer src, long position)`

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

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

- - ### Constructor Detail

    - #### FileBackedDataSource

          public FileBackedDataSource(java.io.File file)
                               throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

    - #### FileBackedDataSource

          public FileBackedDataSource(java.io.File file,
                                      boolean readOnly)
                               throws java.io.FileNotFoundException

      Throws:
        `java.io.FileNotFoundException`

    - #### FileBackedDataSource

          public FileBackedDataSource(java.io.RandomAccessFile srcFile,
                                      boolean readOnly)

    - #### FileBackedDataSource

          public FileBackedDataSource(java.nio.channels.FileChannel channel,
                                      boolean readOnly)

  - ### Method Detail

    - #### isWriteable

          public boolean isWriteable()

    - #### getChannel

          public java.nio.channels.FileChannel getChannel()

    - #### read

          public java.nio.ByteBuffer read(int length,
                                          long position)
                                   throws java.io.IOException

      Specified by:
        `read` in class `DataSource`
      Throws:
        `java.io.IOException`

    - #### write

          public void write(java.nio.ByteBuffer src,
                            long position)
                     throws java.io.IOException

      Specified by:
        `write` in class `DataSource`
      Throws:
        `java.io.IOException`

    - #### copyTo

          public void copyTo(java.io.OutputStream stream)
                      throws java.io.IOException

      Description copied from class: `DataSource`
      Copies the contents to the specified OutputStream
      Specified by:
        `copyTo` in class `DataSource`
      Throws:
        `java.io.IOException`

    - #### size

          public long size()
                    throws java.io.IOException

      Specified by:
        `size` in class `DataSource`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Description copied from class: `DataSource`
      Close the underlying stream
      Specified by:
        `close` in class `DataSource`
      Throws:
        `java.io.IOException`

Copyright 2020 The Apache Software Foundation or its licensors, as applicable.