net.sf.okapi.common

## Class ReaderInputStream

- java.lang.Object
- - java.io.InputStream
  - - net.sf.okapi.common.ReaderInputStream

- All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

      public class ReaderInputStream
      extends java.io.InputStream

  An InputStream backed by a Reader.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected byte[]` | `buffer`
    `protected java.io.ByteArrayOutputStream` | `byteArrayOut`
    `protected char[]` | `chars`
    `protected int` | `index`
    `protected int` | `length`
    `protected java.io.Reader` | `reader`
    `protected java.io.Writer` | `writer`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReaderInputStream(java.io.Reader reader)` Constructor to supply a Reader
    `ReaderInputStream(java.io.Reader reader, java.lang.String encoding)` Constructor to supply a Reader and an encoding

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()`
    `void` | `close()`
    `protected void` | `fillBuffer()`
    `int` | `read()`
    `int` | `read(byte[] data, int off, int len)`

    - ### Methods inherited from class java.io.InputStream

      `mark, markSupported, read, reset, skip`

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

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

- - ### Field Detail

    - #### reader

          protected java.io.Reader reader

    - #### byteArrayOut

          protected java.io.ByteArrayOutputStream byteArrayOut

    - #### writer

          protected java.io.Writer writer

    - #### chars

          protected char[] chars

    - #### buffer

          protected byte[] buffer

    - #### index

          protected int index

    - #### length

          protected int length

  - ### Constructor Detail

    - #### ReaderInputStream

          public ReaderInputStream(java.io.Reader reader)

      Constructor to supply a Reader
      Parameters:
        `reader` - - the Reader used by the InputStream

    - #### ReaderInputStream

          public ReaderInputStream(java.io.Reader reader,
                           java.lang.String encoding)
                            throws java.io.UnsupportedEncodingException

      Constructor to supply a Reader and an encoding
      Parameters:
        `reader` - - the Reader used by the InputStream
        `encoding` - - the encoding to use for the InputStream
      Throws:
        `java.io.UnsupportedEncodingException` - if the encoding is not supported

  - ### Method Detail

    - #### read

          public int read()
                   throws java.io.IOException

      Specified by:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`
      See Also:
        `InputStream.read()`

    - #### fillBuffer

          protected void fillBuffer()
                             throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### read

          public int read(byte[] data,
                 int off,
                 int len)
                   throws java.io.IOException

      Overrides:
        `read` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`
      See Also:
        `InputStream.read(byte[], int, int)`

    - #### available

          public int available()
                        throws java.io.IOException

      Overrides:
        `available` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`
      See Also:
        `InputStream.available()`

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.InputStream`
      Throws:
        `java.io.IOException`
      See Also:
        `InputStream.close()`