ClosedOutputStream (Commons IO 2.5)
Date: 2016-12-01

org.apache.commons.io.output

## Class ClosedOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.apache.commons.io.output.ClosedOutputStream

- All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable

      public class ClosedOutputStream
      extends java.io.OutputStream

  Closed output stream. This stream throws an exception on all attempts to write something to the stream.

  Typically uses of this class include testing for corner cases in methods that accept an output stream and acting as a sentinel value instead of a `null` output stream.

  Since:
    1.4
  Version:
    $Id: ClosedOutputStream.java 1471767 2013-04-24 23:24:19Z sebb $

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static ClosedOutputStream` | `CLOSED_OUTPUT_STREAM` A singleton.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClosedOutputStream()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `write(int b)` Throws an `IOException` to indicate that the stream is closed.

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

      `close, flush, write, write`

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

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

- - ### Field Detail

    - #### CLOSED_OUTPUT_STREAM

          public static final ClosedOutputStream CLOSED_OUTPUT_STREAM

      A singleton.

  - ### Constructor Detail

    - #### ClosedOutputStream

          public ClosedOutputStream()

  - ### Method Detail

    - #### write

          public void write(int b)
                     throws java.io.IOException

      Throws an `IOException` to indicate that the stream is closed.
      Specified by:
        `write` in class `java.io.OutputStream`
      Parameters:
        `b` - ignored
      Throws:
        `java.io.IOException` - always thrown

Copyright (c) 2002-2016 Apache Software Foundation