InputStreamSplitter (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.io
Class InputStreamSplitter

    java.lang.Object
      java.io.InputStream
          java.io.FilterInputStream
              com.bbn.openmap.io.InputStreamSplitter

All Implemented Interfaces:
  java.io.Closeable

    public class InputStreamSplitter

extends java.io.FilterInputStream

The `InputStreamSplitter` is a `FilterInputStream` that reads and returns data from an input stream, while also sending the data to an output stream. Thus, the `InputStreamSplitter` can provide a handy sniffing/logging mechanism. In addition, the output stream could be coupled with a `PipedInputStream` to create two input sources out of a single source.

Field Summary
`protected java.io.OutputStream` | `out` The OutputStream to route the data to.

Fields inherited from class java.io.FilterInputStream
`in`

Constructor Summary
`InputStreamSplitter(java.io.InputStream in, java.io.OutputStream out)` Creates an `InputStreamSplitter`.

Method Summary
`void` | `close()` Closes the input and output streams and releases any system resources associated with those streams.
`void` | `flush()` Flushes the output stream.
`int` | `read()` Reads the next byte of data from the input stream and writes it to the output stream.
`int` | `read(byte[] b)` Reads up to `b.length` bytes of data from this input stream into an array of bytes, and writes those bytes to the output stream.
`int` | `read(byte[] b, int off, int len)` Reads up to `len` bytes of data from this input stream into an array of bytes, and writes those bytes to the output stream.

Methods inherited from class java.io.FilterInputStream
`available, mark, markSupported, reset, skip`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### out

    protected java.io.OutputStream out

  The OutputStream to route the data to.

Constructor Detail

### InputStreamSplitter

    public InputStreamSplitter(java.io.InputStream in,
                               java.io.OutputStream out)

  Creates an `InputStreamSplitter`.

  Parameters:
    `in` - the underlying input stream
    `out` - the output stream

Method Detail

### read

    public int read()
             throws java.io.IOException

  Reads the next byte of data from the input stream and writes it to the output stream. The value byte is returned as an `int` in the range `0` to `255`. If no byte is available because the end of the stream has been reached, the value `-1` is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

  Overrides:
    `read` in class `java.io.FilterInputStream`
  Returns:
    the next byte of data, or `-1` if the end of the stream is reached.
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### read

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

  Reads up to `b.length` bytes of data from this input stream into an array of bytes, and writes those bytes to the output stream. This method blocks until some input is available.

  Overrides:
    `read` in class `java.io.FilterInputStream`
  Parameters:
    `b` - the buffer into which the data is read.
  Returns:
    the total number of bytes read into the buffer, or `-1` if there is no more data because the end of the stream has been reached.
  Throws:
    `java.io.IOException` - if an I/O error occurs.
  See Also:
    `read(byte[], int, int)`

### read

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

  Reads up to `len` bytes of data from this input stream into an array of bytes, and writes those bytes to the output stream. This method blocks until some input is available.

  Overrides:
    `read` in class `java.io.FilterInputStream`
  Parameters:
    `b` - the buffer into which the data is read.
    `off` - the start offset of the data.
    `len` - the maximum number of bytes read.
  Returns:
    the total number of bytes read into the buffer, or `-1` if there is no more data because the end of the stream has been reached.
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### close

    public void close()
               throws java.io.IOException

  Closes the input and output streams and releases any system resources associated with those streams.

  Specified by:
    `close` in interface `java.io.Closeable`
  Overrides:
    `close` in class `java.io.FilterInputStream`
  Throws:
    `java.io.IOException` - if an I/O error occurs.

### flush

    public void flush()
               throws java.io.IOException

  Flushes the output stream.

  Throws:
    `java.io.IOException` - if an I/O error occurs.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details