Class AppendableByteArrayInputStream

java.lang.Object
java.io.InputStream
java.io.ByteArrayInputStream
org.monte.media.io.AppendableByteArrayInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class AppendableByteArrayInputStream extends ByteArrayInputStream
A ByteArrayInputStream which allows to replace the byte buffer underneath.
Author:
Werner Randelshofer
  • Constructor Details

    • AppendableByteArrayInputStream

      public AppendableByteArrayInputStream(byte[] buf, int offset, int length)
    • AppendableByteArrayInputStream

      public AppendableByteArrayInputStream(byte[] buf)
  • Method Details

    • read

      public int read()
      Overrides:
      read in class ByteArrayInputStream
    • read

      public int read(byte[] b, int off, int len)
      Overrides:
      read in class ByteArrayInputStream
    • appendBuffer

      public void appendBuffer(byte[] buf, int offset, int length, boolean discard)
      Appends new data to the buffer.
      Parameters:
      buf - Data.
      offset - Offset in the data.
      length - Length of the data.
      discard - True if data which has already been read can be discarded.
    • setBuffer

      public void setBuffer(byte[] buf, int offset, int length)
      Sets the buffer and resets the stream. This will overwrite the data array in the buffer, if it is large enough. Otherwise it will create a new data array and copy the data into it.
      Parameters:
      buf - Data.
      offset - Offset in the data.
      length - Length of the data.
    • main

      public static void main(String[] args)