org.apache.lucene.mockfile

## Class FilterOutputStream2

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.lucene.mockfile.FilterOutputStream2

All Implemented Interfaces:
  Closeable, Flushable, AutoCloseable

    public abstract class FilterOutputStream2
    extends OutputStream

A `FilterOutputStream2` contains another `OutputStream`, which it uses as its basic source of data, possibly transforming the data along the way or providing additional functionality.

Note: unlike `FilterOutputStream` this class delegates every method by default. This means to transform `write` calls, you need to override multiple methods. On the other hand, it is less trappy: a simple implementation that just overrides `close` will not force bytes to be written one-at-a-time.

### Field Summary

Fields
`protected OutputStream` `delegate` The underlying `OutputStream` instance.

### Constructor Summary

Constructors
Constructor and Description
`FilterOutputStream2(OutputStream delegate)` Construct a `FilterOutputStream2` based on the specified base stream.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()`
`void` `flush()`
`void` `write(byte[] b)`
`void` `write(byte[] b, int off, int len)`
`void` `write(int b)`

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

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

### Field Detail

#### delegate

    protected final OutputStream delegate

The underlying `OutputStream` instance.

### Constructor Detail

#### FilterOutputStream2

    public FilterOutputStream2(OutputStream delegate)

Construct a `FilterOutputStream2` based on the specified base stream.

Note that base stream is closed if this stream is closed.

Parameters:
  `delegate` - specified base stream.

### Method Detail

#### write

    public void write(byte[] b)
               throws IOException

Overrides:
  `write` in class `OutputStream`
Throws:
  `IOException`

#### write

    public void write(byte[] b,
                      int off,
                      int len)
               throws IOException

Overrides:
  `write` in class `OutputStream`
Throws:
  `IOException`

#### flush

    public void flush()
               throws IOException

Specified by:
  `flush` in interface `Flushable`
Overrides:
  `flush` in class `OutputStream`
Throws:
  `IOException`

#### close

    public void close()
               throws IOException

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

#### write

    public void write(int b)
               throws IOException

Specified by:
  `write` in class `OutputStream`
Throws:
  `IOException`