Package com.microej.wear.services

## Interface ExternalResourceService.Writer

- All Superinterfaces:
    `AutoCloseable`, `Closeable`
  Enclosing interface:
    ExternalResourceService

      public static interface ExternalResourceService.Writer
      extends Closeable

  Represents a writer to an external resource.

  A conversion step can be applied when writing or saving the external resource. For example, images can be converted into a specific format before they are stored, depending on how the user will use that resource in the application.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Closes this writer and clears all uncommitted native resources.
    `void` | `commit()` | Flushes all written data and finalizes the resource.
    `void` | `write​(byte[] src, int srcOffset, int length, int destOffset)` | Writes the given data to the external resource.

- - ### Method Detail

    - #### write

          void write​(byte[] src,
                     int srcOffset,
                     int length,
                     int destOffset)
              throws IOException

      Writes the given data to the external resource.
      Parameters:
        `src` - the source array containing the data to write to the external resource.
        `srcOffset` - the offset in the source array of the first byte to write.
        `length` - the number of bytes to write.
        `destOffset` - the offset in the destination (i.e., external resource) at which to write the data.
      Throws:
        `IndexOutOfBoundsException` - if the given srcOffset or the given length is out of the bounds of the source array.
        `IndexOutOfBoundsException` - if the given destOffset or the given length is out of the bounds of the destination.
        `IllegalStateException` - if this writer is closed.
        `IOException` - if an error occurs while writing to the resource.
        `IOException` - if an error occurs during the conversion phase.

    - #### commit

          void commit()
               throws IOException

      Flushes all written data and finalizes the resource.

      After calling this method, the resource is visible and accessible to the application. Any remaining buffered data is written, and the writer is closed, preventing further modifications.

      Throws:
        `IllegalStateException` - if this writer is closed.
        `IOException` - if an error occurs while committing the resource.
        `IOException` - if an error occurred during the conversion phase.

    - #### close

          void close()

      Closes this writer and clears all uncommitted native resources.

      This method does nothing if this writer is already closed.

      Specified by:
        `close` in interface `AutoCloseable`
      Specified by:
        `close` in interface `Closeable`