org.ajax4jsf.io

## Class FastBufferOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.ajax4jsf.io.FastBufferOutputStream

- All Implemented Interfaces:
    Closeable, Flushable, AutoCloseable

      public class FastBufferOutputStream
      extends OutputStream

  Class for writing to chain of byte arrays extending OutputStream.
  Author:
    glory

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FastBufferOutputStream()` Creates instance of default initial capacity.
    `FastBufferOutputStream(ByteBuffer firstBuffer)` Creates instance for an already existing chain of byte arrays.
    `FastBufferOutputStream(int initialSize)` Creates instance with required initial capacity.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `FastBufferWriter` | `convertToWriter()` Returns instance of FastBufferWriter containing all data written to this output stream.
    `FastBufferWriter` | `convertToWriter(String encoding)` Returns instance of FastBufferWriter containing all data written to this output stream.
    `ByteBuffer` | `getFirstBuffer()` Returns the first link of the chain of byte arrays.
    `int` | `getLength()` Returns the total number of written bytes.
    `void` | `reset()` Resets stream to empty state
    `byte[]` | `toByteArray()`
    `void` | `write(byte[] b)`
    `void` | `write(byte[] b, int off, int len)`
    `void` | `write(int c)`
    `void` | `writeTo(OutputStream out)` Writes all data written up to the moment to out.
    `void` | `writeTo(Writer out, String encoding)` Writes all data written up to the moment to out.

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

      `close, flush`

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

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

- - ### Constructor Detail

    - #### FastBufferOutputStream

          public FastBufferOutputStream()

      Creates instance of default initial capacity.

    - #### FastBufferOutputStream

          public FastBufferOutputStream(ByteBuffer firstBuffer)

      Creates instance for an already existing chain of byte arrays.
      Parameters:
        `firstBuffer` -

    - #### FastBufferOutputStream

          public FastBufferOutputStream(int initialSize)

      Creates instance with required initial capacity.
      Parameters:
        `initialSize` -

  - ### Method Detail

    - #### write

          public void write(int c)
                     throws IOException

      Specified by:
        `write` in class `OutputStream`
      Throws:
        `IOException`
      See Also:
        `OutputStream.write(int)`

    - #### write

          public void write(byte[] b)
                     throws IOException

      Overrides:
        `write` in class `OutputStream`
      Throws:
        `IOException`
      See Also:
        `OutputStream.write(byte [])`

    - #### write

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

      Overrides:
        `write` in class `OutputStream`
      Throws:
        `IOException`
      See Also:
        `OutputStream.write(byte[], int, int)`

    - #### getLength

          public int getLength()

      Returns the total number of written bytes.
      Returns:
        the total number of written bytes

    - #### getFirstBuffer

          public ByteBuffer getFirstBuffer()

      Returns the first link of the chain of byte arrays.
      Returns:
        the first link of the chain of byte arrays

    - #### toByteArray

          public byte[] toByteArray()

    - #### writeTo

          public void writeTo(OutputStream out)
                       throws IOException

      Writes all data written up to the moment to out.
      Parameters:
        `out` -
      Throws:
        `IOException`

    - #### writeTo

          public void writeTo(Writer out,
                     String encoding)
                       throws IOException

      Writes all data written up to the moment to out.
      Parameters:
        `out` -
      Throws:
        `IOException`

    - #### convertToWriter

          public FastBufferWriter convertToWriter(String encoding)
                                           throws UnsupportedEncodingException

      Returns instance of FastBufferWriter containing all data written to this output stream.
      Parameters:
        `encoding` -
      Returns:
        instance of FastBufferWriter containing all data written to this output stream
      Throws:
        `UnsupportedEncodingException`

    - #### convertToWriter

          public FastBufferWriter convertToWriter()

      Returns instance of FastBufferWriter containing all data written to this output stream.
      Returns:
        instance of FastBufferWriter containing all data written to this output stream

    - #### reset

          public void reset()

      Resets stream to empty state
      Since:
        3.3.0

Copyright © 2015 JBoss by Red Hat. All Rights Reserved.