lev

## Class FastByteArrayOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - lev.FastByteArrayOutputStream

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

      public class FastByteArrayOutputStream
      extends java.io.OutputStream

  ByteArrayOutputStream implementation that doesn't synchronize methods and doesn't copy the data on toByteArray().

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected byte[]` | `buf` Buffer and size
    `protected int` | `size`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FastByteArrayOutputStream()` Constructs a stream with buffer capacity size 5K
    `FastByteArrayOutputStream(int initSize)` Constructs a stream with the given initial size

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `byte[]` | `getByteArray()` Returns the byte array containing the written data.
    `java.io.InputStream` | `getInputStream()` Returns a ByteArrayInputStream for reading back the written data
    `int` | `getSize()`
    `void` | `reset()`
    `void` | `write(byte[] b)`
    `void` | `write(byte[] b, int off, int len)`
    `void` | `write(int b)`

    - ### 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`

- - ### Field Detail

    - #### buf

          protected byte[] buf

      Buffer and size

    - #### size

          protected int size

  - ### Constructor Detail

    - #### FastByteArrayOutputStream

          public FastByteArrayOutputStream()

      Constructs a stream with buffer capacity size 5K

    - #### FastByteArrayOutputStream

          public FastByteArrayOutputStream(int initSize)

      Constructs a stream with the given initial size
      Parameters:
        `initSize` -

  - ### Method Detail

    - #### getSize

          public int getSize()

      Returns:

    - #### getByteArray

          public byte[] getByteArray()

      Returns the byte array containing the written data. Note that this array will almost always be larger than the amount of data actually written.
      Returns:

    - #### write

          public final void write(byte[] b)

      Overrides:
        `write` in class `java.io.OutputStream`
      Parameters:
        `b` -

    - #### write

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

      Overrides:
        `write` in class `java.io.OutputStream`
      Parameters:
        `b` -
        `off` -
        `len` -

    - #### write

          public final void write(int b)

      Specified by:
        `write` in class `java.io.OutputStream`
      Parameters:
        `b` -

    - #### reset

          public void reset()

    - #### getInputStream

          public java.io.InputStream getInputStream()

      Returns a ByteArrayInputStream for reading back the written data
      Returns: