Class FastByteArrayOutputStream

java.lang.Object
java.io.OutputStream
com.jbstrap.core.utils.FastByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class FastByteArrayOutputStream extends OutputStream
Since:
4.0
Author:
JBStrap
  • Field Details

    • buf

      protected byte[] buf
    • size

      protected int size
  • Constructor Details

    • 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 - The initial size in byte
  • Method Details

    • getSize

      public int getSize()
    • 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:
      The byte array
    • write

      public final void write(byte[] b)
      Overrides:
      write in class OutputStream
    • write

      public final void write(byte[] b, int off, int len)
      Overrides:
      write in class OutputStream
    • write

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

      public void reset()
    • getInputStream

      public InputStream getInputStream()
      Returns a ByteArrayInputStream for reading back the written data
      Returns:
      The ByteArrayInputStream