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

## edu.emory.mathcs.util.io
Class RedirectingInputStream

    java.lang.Object
      java.io.InputStream
          java.io.FilterInputStream
              edu.emory.mathcs.util.io.RedirectingInputStream

All Implemented Interfaces:
  Input, RedirectibleInput

public class RedirectingInputStream
extends java.io.FilterInputStream
implements RedirectibleInput

Input stream that supports redirecting data directly to an output stream.

Version:
  1.0
Author:
  Dawid Kurzyniec
See Also:
  `TeeInputStream`, `ForkOutputStream`, `RedirectingReader`

Field Summary

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

Constructor Summary
`RedirectingInputStream(java.io.InputStream in)` Creates a new redirecting input stream that reads from the specified source with default autoflush and autoclose policies and a default buffer size of 2KB.
`RedirectingInputStream(java.io.InputStream in, boolean autoFlush, boolean autoClose)` Creates a new redirecting input stream that reads from the specified source, has specified autoflush and autoclose policy and a default buffer size of 2KB.
`RedirectingInputStream(java.io.InputStream in, boolean autoFlush, boolean autoClose, int buflen)` Creates a new redirecting input stream that reads from the specified source, has specified autoflush and autoclose policy, and a given buffer size.
`RedirectingInputStream(java.io.InputStream in, int buflen)` Creates a new redirecting input stream that reads from the specified source with default autoflush and autoclose policies and a specified buffer size.

Method Summary
`int` | `redirect(java.io.OutputStream out, int len)` Reads and redirects up to the `len` bytes of data to a specified output stream.
`int` | `redirectAll(java.io.OutputStream out)` Readirects all further data from this input into the specified output stream, until EOF.

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

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

Methods inherited from interface edu.emory.mathcs.util.io.Input
`available, close, mark, markSupported, read, read, read, reset, skip`

Constructor Detail

### RedirectingInputStream

    public RedirectingInputStream(java.io.InputStream in)

  Creates a new redirecting input stream that reads from the specified source with default autoflush and autoclose policies and a default buffer size of 2KB. The default autoflush policy is to flush the output after redirecting every chunk of data. The default autoclose policy is not to close the output upon EOF on the input during redirection.

Parameters:
  `in` - the input to read from

### RedirectingInputStream

    public RedirectingInputStream(java.io.InputStream in,
                                  int buflen)

  Creates a new redirecting input stream that reads from the specified source with default autoflush and autoclose policies and a specified buffer size. The default autoflush policy is to flush the output after redirecting every chunk of data. The default autoclose policy is not to close the output upon EOF on the input during redirection. Buffer length is the maximum chunk size.

Parameters:
  `in` - the input to read from
  `buflen` - the maximum chunk size

### RedirectingInputStream

    public RedirectingInputStream(java.io.InputStream in,
                                  boolean autoFlush,
                                  boolean autoClose)

  Creates a new redirecting input stream that reads from the specified source, has specified autoflush and autoclose policy and a default buffer size of 2KB. The autoFlush parameter decides whether the output should be automatically flushed after every chunk of redirected data. The autoClose parameter decides whether the output should be closed upon EOF on the input during redirection.

Parameters:
  `in` - the input to read from
  `autoFlush` - decides whether to flush the output after each redirect
  `autoClose` - decides whether to close the output upon EOF on input during redirection

### RedirectingInputStream

    public RedirectingInputStream(java.io.InputStream in,
                                  boolean autoFlush,
                                  boolean autoClose,
                                  int buflen)

  Creates a new redirecting input stream that reads from the specified source, has specified autoflush and autoclose policy, and a given buffer size. The autoFlush parameter decides whether the output should be automatically flushed after every chunk of redirected data. The autoClose parameter decides whether the output should be closed upon EOF on the input during redirection. Buffer length is the maximum chunk size.

Parameters:
  `in` - the input to read from
  `autoFlush` - decides whether to flush the output after each redirect
  `autoClose` - decides whether to close the output upon EOF on input during redirection
  `buflen` - the maximum chunk size

Method Detail

### redirect

    public int redirect(java.io.OutputStream out,
                        int len)
                 throws java.io.IOException

  Description copied from interface: `RedirectibleInput`
  Reads and redirects up to the `len` bytes of data to a specified output stream. Returns the number of bytes actually redirected.

  Specified by:
    `redirect` in interface `RedirectibleInput`
  Parameters:
    `out` - the destination stream
    `len` - the maximum number of bytes to redirect
  Returns:
    number of bytes actually redirected
  Throws:
    `java.io.IOException` - if I/O error occurs

### redirectAll

    public int redirectAll(java.io.OutputStream out)
                    throws java.io.IOException

  Description copied from interface: `RedirectibleInput`
  Readirects all further data from this input into the specified output stream, until EOF. Returns the number of bytes actually redirected.

  Specified by:
    `redirectAll` in interface `RedirectibleInput`
  Parameters:
    `out` - the destination stream
  Returns:
    number of bytes actually redirected
  Throws:
    `java.io.IOException` - if I/O error occurs

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