org.apache.commons.net.telnet

## Class TelnetInputStream

- java.lang.Object
- - java.io.InputStream
  - - java.io.FilterInputStream
    - - java.io.BufferedInputStream
      - - org.apache.commons.net.telnet.TelnetInputStream

- All Implemented Interfaces:
    Closeable, AutoCloseable, Runnable

      final class TelnetInputStream
      extends BufferedInputStream
      implements Runnable

  TelnetInputStream extends BufferedInputStream to provide Telnet protocol-specific input handling. This class processes Telnet commands and options while providing a standard InputStream interface.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) static int` | `STATE_CR`
    `(package private) static int` | `STATE_DATA`
    `(package private) static int` | `STATE_DO`
    `(package private) static int` | `STATE_DONT`
    `(package private) static int` | `STATE_IAC`
    `(package private) static int` | `STATE_IAC_SB`
    `(package private) static int` | `STATE_SB`
    `(package private) static int` | `STATE_SE`
    `(package private) static int` | `STATE_WILL`
    `(package private) static int` | `STATE_WONT`

    - ### Fields inherited from class java.io.BufferedInputStream

      `buf, count, marklimit, markpos, pos`

    - ### Fields inherited from class java.io.FilterInputStream

      `in`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `TelnetInputStream(InputStream input, TelnetClient client)`
    `TelnetInputStream(InputStream input, TelnetClient client, boolean readerThread)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `available()`
    `void` | `close()`
    `boolean` | `markSupported()` Returns false.
    `int` | `read()`
    `int` | `read(byte[] buffer)` Reads the next number of bytes from the stream into an array and returns the number of bytes read.
    `int` | `read(byte[] buffer, int offset, int length)` Reads the next number of bytes from the stream into an array and returns the number of bytes read.
    `void` | `run()`
    `(package private) void` | `start()`

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

      `mark, reset, skip`

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

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

- - ### Field Detail

    - #### STATE_CR

          static final int STATE_CR

      See Also:
        Constant Field Values

    - #### STATE_DATA

          static final int STATE_DATA

      See Also:
        Constant Field Values

    - #### STATE_DO

          static final int STATE_DO

      See Also:
        Constant Field Values

    - #### STATE_DONT

          static final int STATE_DONT

      See Also:
        Constant Field Values

    - #### STATE_IAC

          static final int STATE_IAC

      See Also:
        Constant Field Values

    - #### STATE_IAC_SB

          static final int STATE_IAC_SB

      See Also:
        Constant Field Values

    - #### STATE_SB

          static final int STATE_SB

      See Also:
        Constant Field Values

    - #### STATE_SE

          static final int STATE_SE

      See Also:
        Constant Field Values

    - #### STATE_WILL

          static final int STATE_WILL

      See Also:
        Constant Field Values

    - #### STATE_WONT

          static final int STATE_WONT

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### TelnetInputStream

          TelnetInputStream(InputStream input,
                            TelnetClient client)

    - #### TelnetInputStream

          TelnetInputStream(InputStream input,
                            TelnetClient client,
                            boolean readerThread)

  - ### Method Detail

    - #### available

          public int available()
                        throws IOException

      Overrides:
        `available` in class `BufferedInputStream`
      Throws:
        `IOException`

    - #### close

          public void close()
                     throws IOException

      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Overrides:
        `close` in class `BufferedInputStream`
      Throws:
        `IOException`

    - #### markSupported

          public boolean markSupported()

      Returns false. Mark is not supported.
      Overrides:
        `markSupported` in class `BufferedInputStream`

    - #### read

          public int read()
                   throws IOException

      Overrides:
        `read` in class `BufferedInputStream`
      Throws:
        `IOException`

    - #### read

          public int read(byte[] buffer)
                   throws IOException

      Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the stream has been reached.
      Overrides:
        `read` in class `FilterInputStream`
      Parameters:
        `buffer` - The byte array in which to store the data.
      Returns:
        The number of bytes read. Returns -1 if the end of the message has been reached.
      Throws:
        `IOException` - If an error occurs in reading the underlying stream.

    - #### read

          public int read(byte[] buffer,
                          int offset,
                          int length)
                   throws IOException

      Reads the next number of bytes from the stream into an array and returns the number of bytes read. Returns -1 if the end of the message has been reached. The characters are stored in the array starting from the given offset and up to the length specified.
      Overrides:
        `read` in class `BufferedInputStream`
      Parameters:
        `buffer` - The byte array in which to store the data.
        `offset` - The offset into the array at which to start storing data.
        `length` - The number of bytes to read.
      Returns:
        The number of bytes read. Returns -1 if the end of the stream has been reached.
      Throws:
        `IOException` - If an error occurs while reading the underlying stream.

    - #### run

          public void run()

      Specified by:
        `run` in interface `Runnable`

    - #### start

          void start()