Class BlockedByteArrayOutputStream

java.lang.Object
java.io.OutputStream
org.apache.derby.impl.io.vfmem.BlockedByteArrayOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class BlockedByteArrayOutputStream extends OutputStream
Output stream writing bytes into an underlying blocked byte array.
  • Field Details

    • src

      private BlockedByteArray src
      The underlying destination. Set to null when closed.
    • pos

      private long pos
      The current position of the stream.
  • Constructor Details

    • BlockedByteArrayOutputStream

      public BlockedByteArrayOutputStream(BlockedByteArray src, long pos)
      Creates a new stream writing data into the specified blocked byte array.
      Parameters:
      src - the underlying blocked byte array
      pos - the initial position of stream
  • Method Details

    • setPosition

      void setPosition(long newPos)
      Sets the position.
      Parameters:
      newPos - the new byte position
    • getPosition

      long getPosition()
      Returns the current position.
      Returns:
      The current byte position.
    • write

      public void write(int b)
      Writes the single byte into the underlying blocked byte array.
      Specified by:
      write in class OutputStream
      Parameters:
      b - the byte to write
    • write

      public void write(byte[] buf, int offset, int len)
      Writes the specified bytes into the underlying blocked byte array.
      Overrides:
      write in class OutputStream
      Parameters:
      buf - source byte array
      offset - index of the first byte to write
      len - the number of bytes to write
    • close

      public void close()
      Closes the stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream