Class FastByteArrayOutputStream

java.lang.Object
java.io.OutputStream
io.fusionauth.http.io.FastByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class FastByteArrayOutputStream extends OutputStream
A simple fast byte array output stream. This does no checks and has no synchronization. It simply jams data in an array and resizes in increments (set in the constructor).
Author:
Brian Pontarelli
  • Field Details

    • buffer

      protected byte[] buffer
    • count

      protected int count
    • growthRate

      protected int growthRate
  • Constructor Details

    • FastByteArrayOutputStream

      public FastByteArrayOutputStream(int size, int growthRate)
      Creates a new FastByteArrayOutputStream with the given size.
      Parameters:
      size - The initial size of the buffer.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
    • reset

      public void reset()
      Resets this output stream by setting the count to 0.
    • size

      public int size()
      Returns:
      The number of bytes that have been written to the output stream.
    • bytes

      public byte[] bytes()
      Returns:
      The byte array (directly without copying).
    • write

      public void write(int b)
      Specified by:
      write in class OutputStream
    • write

      public void write(byte[] source, int offset, int length)
      Overrides:
      write in class OutputStream
    • write

      public void write(byte[] source) throws IOException
      Overrides:
      write in class OutputStream
      Throws:
      IOException