org.restlet.engine.io

## Class ReaderInputStream

- java.lang.Object
- - java.io.InputStream
  - - org.restlet.engine.io.ReaderInputStream

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

    public class ReaderInputStream
    extends java.io.InputStream

Input stream based on a reader. The implementation relies on the NIO `CharsetEncoder` class.

Author:
  Jerome Louvel

### Constructor Summary

Constructors
Constructor and Description
`ReaderInputStream(java.io.Reader reader)` Constructor.
`ReaderInputStream(java.io.Reader reader, CharacterSet characterSet)` Constructor.

### Method Summary

Methods
`int` `available()`
`void` `close()` Closes the wrapped reader.
`int` `read()`
`int` `read(byte[] b, 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`

### Constructor Detail

#### ReaderInputStream

    public ReaderInputStream(java.io.Reader reader)
                      throws java.io.IOException

Constructor. Uses the `CharacterSet.ISO_8859_1` character set by default.

Parameters:
  `reader` - The reader to wrap as an input stream.
Throws:
  `java.io.IOException`

#### ReaderInputStream

    public ReaderInputStream(java.io.Reader reader,
                     CharacterSet characterSet)
                      throws java.io.IOException

Constructor.

Parameters:
  `reader` - The reader to wrap as an input stream.
  `characterSet` - The character set to use for encoding.
Throws:
  `java.io.IOException`

### Method Detail

#### available

    public int available()
                  throws java.io.IOException

Overrides:
  `available` in class `java.io.InputStream`
Throws:
  `java.io.IOException`

#### close

    public void close()
               throws java.io.IOException

Closes the wrapped reader.

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`

#### read

    public int read()
             throws java.io.IOException

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

#### read

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

Overrides:
  `read` in class `java.io.InputStream`
Throws:
  `java.io.IOException`