Package org.apache.commons.io.build

# Class AbstractOrigin.WriterOrigin

java.lang.Object
org.apache.commons.io.build.AbstractSupplier<Writer,AbstractOrigin.WriterOrigin>
org.apache.commons.io.build.AbstractOrigin<Writer,AbstractOrigin.WriterOrigin>
org.apache.commons.io.build.AbstractOrigin.WriterOrigin

All Implemented Interfaces:
  `IOSupplier<Writer>`

Enclosing class:
  `AbstractOrigin<T,B extends AbstractOrigin<T,B>>`

public static class AbstractOrigin.WriterOrigin extends AbstractOrigin<Writer,AbstractOrigin.WriterOrigin>
A `Writer` origin.

This origin cannot provide conversions to other aspects.

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from class org.apache.commons.io.build.AbstractOrigin

  `AbstractOrigin.AbstractRandomAccessFileOrigin<T extends RandomAccessFile,B extends AbstractOrigin.AbstractRandomAccessFileOrigin<T,B>>, AbstractOrigin.ByteArrayOrigin, AbstractOrigin.ChannelOrigin, AbstractOrigin.CharSequenceOrigin, AbstractOrigin.FileOrigin, AbstractOrigin.InputStreamOrigin, AbstractOrigin.IORandomAccessFileOrigin, AbstractOrigin.OutputStreamOrigin, AbstractOrigin.PathOrigin, AbstractOrigin.RandomAccessFileOrigin, AbstractOrigin.ReaderOrigin, AbstractOrigin.URIOrigin, AbstractOrigin.WriterOrigin`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WriterOrigin(Writer origin)`
  Constructs a new instance for the given origin.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected Channel`
  `getChannel(OpenOption... options)`
  Gets this origin as a Channel, if possible.
  `OutputStream`
  `getOutputStream(OpenOption... options)`
  Gets this origin as an OutputStream, if possible.
  `Writer`
  `getWriter(Charset charset, OpenOption... options)`
  Gets a new Writer on the origin, buffered by default.

  ### Methods inherited from class org.apache.commons.io.build.AbstractOrigin

  `get, getByteArray, getByteArray, getChannel, getCharSequence, getFile, getInputStream, getPath, getRandomAccessFile, getReader, size, toString`

  ### Methods inherited from class org.apache.commons.io.build.AbstractSupplier

  `asThis`

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

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

  ### Methods inherited from interface org.apache.commons.io.function.IOSupplier

  `asSupplier, getUnchecked`

- ## Constructor Details

  - ### WriterOrigin

    public WriterOrigin(Writer origin)
    Constructs a new instance for the given origin.
    Parameters:
      `origin` - The origin, not null.
    Throws:
      `NullPointerException` - if `origin` is `null`.

- ## Method Details

  - ### getChannel

    protected Channel getChannel(OpenOption... options) throws IOException
    Description copied from class: `AbstractOrigin`
    Gets this origin as a Channel, if possible.
    Overrides:
      `getChannel` in class `AbstractOrigin<Writer,AbstractOrigin.WriterOrigin>`
    Parameters:
      `options` - Options specifying how a file-based origin is opened, ignored otherwise.
    Returns:
      A new Channel on the origin.
    Throws:
      `IOException` - If an I/O error occurs.
    See Also:
      - `AbstractOrigin.getChannel(Class, OpenOption...)`

  - ### getOutputStream

    public OutputStream getOutputStream(OpenOption... options) throws IOException
    Gets this origin as an OutputStream, if possible.

    The `options` parameter is ignored since a `Writer` does not need an `OpenOption` to be written.

    Overrides:
      `getOutputStream` in class `AbstractOrigin<Writer,AbstractOrigin.WriterOrigin>`
    Parameters:
      `options` - options specifying how the file is opened.
    Returns:
      this origin as an OutputStream, if possible.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### getWriter

    public Writer getWriter(Charset charset, OpenOption... options) throws IOException
    Gets a new Writer on the origin, buffered by default.

    The `charset` parameter is ignored since a `Writer` does not need a `Charset` to be written.

    The `options` parameter is ignored since a `Writer` does not need an `OpenOption` to be written.

    No conversion should occur when calling this method.

    Overrides:
      `getWriter` in class `AbstractOrigin<Writer,AbstractOrigin.WriterOrigin>`
    Parameters:
      `charset` - the charset to use for encoding.
      `options` - options specifying how the file is opened.
    Returns:
      a new Writer on the origin.
    Throws:
      `IOException` - if an I/O error occurs opening or creating the file.