Class ByteArrayOutputStream

java.lang.Object
java.io.OutputStream
org.fusesource.hawtbuf.ByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class ByteArrayOutputStream extends OutputStream
Very similar to the java.io.ByteArrayOutputStream but this version is not thread safe and the resulting data is returned in a Buffer to avoid an extra byte[] allocation.
  • Field Details

    • buffer

      byte[] buffer
    • size

      int size
  • Constructor Details

    • ByteArrayOutputStream

      public ByteArrayOutputStream()
    • ByteArrayOutputStream

      public ByteArrayOutputStream(int capacity)
  • Method Details

    • write

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

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

      public void write(Buffer b)
    • checkCapacity

      private void checkCapacity(int minimumCapacity)
      Ensures the the buffer has at least the minimumCapacity specified.
      Parameters:
      minimumCapacity -
    • reset

      public void reset()
    • toBuffer

      public Buffer toBuffer()
    • toByteArray

      public byte[] toByteArray()
    • size

      public int size()