org.apache.thrift.transport

## Class TIOStreamTransport

- java.lang.Object
- - org.apache.thrift.transport.TTransport
  - - org.apache.thrift.transport.TIOStreamTransport

- Direct Known Subclasses:
    TSocket

      public class TIOStreamTransport
      extends TTransport

  This is the most commonly used base transport. It takes an InputStream and an OutputStream and uses those to perform all transport operations. This allows for compatibility with all the nice constructs Java already has to provide a variety of types of streams.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.io.InputStream` | `inputStream_` Underlying inputStream
    `protected java.io.OutputStream` | `outputStream_` Underlying outputStream

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `TIOStreamTransport()` Subclasses can invoke the default constructor and then assign the input streams in the open method.
    `` | `TIOStreamTransport(java.io.InputStream is)` Input stream constructor.
    `` | `TIOStreamTransport(java.io.InputStream is, java.io.OutputStream os)` Two-way stream constructor.
    `` | `TIOStreamTransport(java.io.OutputStream os)` Output stream constructor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes both the input and output streams.
    `void` | `flush()` Flushes the underlying output stream if not null.
    `boolean` | `isOpen()` The streams must already be open at construction time, so this should always return true.
    `void` | `open()` The streams must already be open.
    `int` | `read(byte[] buf, int off, int len)` Reads from the underlying input stream if not null.
    `void` | `write(byte[] buf, int off, int len)` Writes to the underlying output stream if not null.

    - ### Methods inherited from class org.apache.thrift.transport.TTransport

      `consumeBuffer, getBuffer, getBufferPosition, getBytesRemainingInBuffer, peek, readAll, write`

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

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

- - ### Field Detail

    - #### inputStream_

          protected java.io.InputStream inputStream_

      Underlying inputStream

    - #### outputStream_

          protected java.io.OutputStream outputStream_

      Underlying outputStream

  - ### Constructor Detail

    - #### TIOStreamTransport

          protected TIOStreamTransport()

      Subclasses can invoke the default constructor and then assign the input streams in the open method.

    - #### TIOStreamTransport

          public TIOStreamTransport(java.io.InputStream is)

      Input stream constructor.
      Parameters:
        `is` - Input stream to read from

    - #### TIOStreamTransport

          public TIOStreamTransport(java.io.OutputStream os)

      Output stream constructor.
      Parameters:
        `os` - Output stream to read from

    - #### TIOStreamTransport

          public TIOStreamTransport(java.io.InputStream is,
                            java.io.OutputStream os)

      Two-way stream constructor.
      Parameters:
        `is` - Input stream to read from
        `os` - Output stream to read from

  - ### Method Detail

    - #### isOpen

          public boolean isOpen()

      The streams must already be open at construction time, so this should always return true.
      Specified by:
        `isOpen` in class `TTransport`
      Returns:
        true

    - #### open

          public void open()
                    throws TTransportException

      The streams must already be open. This method does nothing.
      Specified by:
        `open` in class `TTransport`
      Throws:
        `TTransportException` - if the transport could not be opened

    - #### close

          public void close()

      Closes both the input and output streams.
      Specified by:
        `close` in class `TTransport`

    - #### read

          public int read(byte[] buf,
                 int off,
                 int len)
                   throws TTransportException

      Reads from the underlying input stream if not null.
      Specified by:
        `read` in class `TTransport`
      Parameters:
        `buf` - Array to read into
        `off` - Index to start reading at
        `len` - Maximum number of bytes to read
      Returns:
        The number of bytes actually read
      Throws:
        `TTransportException` - if there was an error reading data

    - #### write

          public void write(byte[] buf,
                   int off,
                   int len)
                     throws TTransportException

      Writes to the underlying output stream if not null.
      Specified by:
        `write` in class `TTransport`
      Parameters:
        `buf` - The output data buffer
        `off` - The offset to start writing from
        `len` - The number of bytes to write
      Throws:
        `TTransportException` - if there was an error writing data

    - #### flush

          public void flush()
                     throws TTransportException

      Flushes the underlying output stream if not null.
      Overrides:
        `flush` in class `TTransport`
      Throws:
        `TTransportException` - if there was an error writing out data.