BufferingOutputStream (Bouncy Castle Library 1.52 API Specification)

org.bouncycastle.util.io

## Class BufferingOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.bouncycastle.util.io.BufferingOutputStream

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

      public class BufferingOutputStream
      extends java.io.OutputStream

  An output stream that buffers data to be feed into an encapsulated output stream.

  The stream zeroes out the internal buffer on each flush.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `BufferingOutputStream(java.io.OutputStream other)` Create a buffering stream with the default buffer size (4096).
    `BufferingOutputStream(java.io.OutputStream other, int bufferSize)` Create a buffering stream with a specified buffer size.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `flush()` Flush the internal buffer to the encapsulated output stream.
    `void` | `write(byte[] bytes, int offset, int len)`
    `void` | `write(int b)`

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

      `write`

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

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

- - ### Constructor Detail

    - #### BufferingOutputStream

          public BufferingOutputStream(java.io.OutputStream other)

      Create a buffering stream with the default buffer size (4096).
      Parameters:
        `other` - output stream to be wrapped.

    - #### BufferingOutputStream

          public BufferingOutputStream(java.io.OutputStream other,
                               int bufferSize)

      Create a buffering stream with a specified buffer size.
      Parameters:
        `other` - output stream to be wrapped.
        `bufferSize` - size in bytes for internal buffer.

  - ### Method Detail

    - #### write

          public void write(byte[] bytes,
                   int offset,
                   int len)
                     throws java.io.IOException

      Overrides:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### write

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

      Specified by:
        `write` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### flush

          public void flush()
                     throws java.io.IOException

      Flush the internal buffer to the encapsulated output stream. Zero the buffer contents when done.
      Specified by:
        `flush` in interface `java.io.Flushable`
      Overrides:
        `flush` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException` - on error.

    - #### close

          public void close()
                     throws java.io.IOException

      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Overrides:
        `close` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`