org.apache.commons.io.build

## Class AbstractOrigin.ReaderOrigin

- java.lang.Object
- - org.apache.commons.io.build.AbstractSupplier<T,B>
  - - org.apache.commons.io.build.AbstractOrigin<Reader,AbstractOrigin.ReaderOrigin>
    - - org.apache.commons.io.build.AbstractOrigin.ReaderOrigin

- All Implemented Interfaces:
    IOSupplier<Reader>
  Enclosing class:
    AbstractOrigin<T,B extends AbstractOrigin<T,B>>

      public static class AbstractOrigin.ReaderOrigin
      extends AbstractOrigin<Reader,AbstractOrigin.ReaderOrigin>

  An `Reader` origin.

  This origin cannot provide other aspects.

- - ### Nested Class Summary

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

      `AbstractOrigin.ByteArrayOrigin, AbstractOrigin.CharSequenceOrigin, AbstractOrigin.FileOrigin, AbstractOrigin.InputStreamOrigin, AbstractOrigin.OutputStreamOrigin, AbstractOrigin.PathOrigin, AbstractOrigin.ReaderOrigin, AbstractOrigin.URIOrigin, AbstractOrigin.WriterOrigin`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReaderOrigin(Reader origin)` Constructs a new instance for the given origin.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getByteArray()` Gets this origin as a byte array, if possible.
    `CharSequence` | `getCharSequence(Charset charset)` Gets this origin as a byte array, if possible.
    `InputStream` | `getInputStream(OpenOption... options)` Gets this origin as an InputStream, if possible.
    `Reader` | `getReader(Charset charset)` Gets a new Reader on the origin, buffered by default.

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

      `get, getByteArray, getFile, getOutputStream, getPath, getWriter, 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`

- - ### Constructor Detail

    - #### ReaderOrigin

          public ReaderOrigin(Reader origin)

      Constructs a new instance for the given origin.
      Parameters:
        `origin` - The origin.

  - ### Method Detail

    - #### getByteArray

          public byte[] getByteArray()
                              throws IOException

      Description copied from class: `AbstractOrigin`
      Gets this origin as a byte array, if possible.
      Overrides:
        `getByteArray` in class `AbstractOrigin<Reader,AbstractOrigin.ReaderOrigin>`
      Returns:
        this origin as a byte array, if possible.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### getCharSequence

          public CharSequence getCharSequence(Charset charset)
                                       throws IOException

      Description copied from class: `AbstractOrigin`
      Gets this origin as a byte array, if possible.
      Overrides:
        `getCharSequence` in class `AbstractOrigin<Reader,AbstractOrigin.ReaderOrigin>`
      Parameters:
        `charset` - The charset to use if conversion from bytes is needed.
      Returns:
        this origin as a byte array, if possible.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### getInputStream

          public InputStream getInputStream(OpenOption... options)
                                     throws IOException

      Description copied from class: `AbstractOrigin`
      Gets this origin as an InputStream, if possible.
      Overrides:
        `getInputStream` in class `AbstractOrigin<Reader,AbstractOrigin.ReaderOrigin>`
      Parameters:
        `options` - options specifying how the file is opened
      Returns:
        this origin as an InputStream, if possible.
      Throws:
        `IOException` - if an I/O error occurs.

    - #### getReader

          public Reader getReader(Charset charset)
                           throws IOException

      Description copied from class: `AbstractOrigin`
      Gets a new Reader on the origin, buffered by default.
      Overrides:
        `getReader` in class `AbstractOrigin<Reader,AbstractOrigin.ReaderOrigin>`
      Parameters:
        `charset` - the charset to use for decoding
      Returns:
        a new Reader on the origin.
      Throws:
        `IOException` - if an I/O error occurs opening the file.

Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.