Class ArrayOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable, Limit

    public class ArrayOutputStream
    extends java.io.OutputStream
    implements Limit
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int end  
      private byte[] pageData  
      private int position  
      private int start  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int clearLimit()
      Clear any limit set by setLimit.
      int getPosition()  
      void setData​(byte[] data)  
      void setLimit​(int length)
      Set the limit of the data that can be read or written.
      void setPosition​(int newPosition)
      Set the position of the stream pointer.
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.OutputStream

        close, flush, nullOutputStream, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • pageData

        private byte[] pageData
      • start

        private int start
      • end

        private int end
      • position

        private int position
    • Constructor Detail

      • ArrayOutputStream

        public ArrayOutputStream()
      • ArrayOutputStream

        public ArrayOutputStream​(byte[] data)
    • Method Detail

      • setData

        public void setData​(byte[] data)
      • write

        public void write​(int b)
                   throws java.io.IOException
        Specified by:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.OutputStream
        Throws:
        java.io.IOException
      • getPosition

        public int getPosition()
      • setPosition

        public void setPosition​(int newPosition)
                         throws java.io.IOException
        Set the position of the stream pointer.
        Throws:
        java.io.IOException
      • setLimit

        public void setLimit​(int length)
                      throws java.io.IOException
        Description copied from interface: Limit
        Set the limit of the data that can be read or written. After this call up to and including length bytes can be read from or skipped in the stream.

        On input classes (e.g. InputStreams) any attempt to read or skip beyond the limit will result in an end of file indication (e.g. read() methods returning -1 or throwing EOFException).

        On output classes (e.g. OutputStream) any attempt to write more beyond the limit will result in an EOFException

        Specified by:
        setLimit in interface Limit
        Throws:
        java.io.IOException - IOException from some underlying stream
        java.io.EOFException - The set limit would exceed the available data in the stream.
      • clearLimit

        public int clearLimit()
        Description copied from interface: Limit
        Clear any limit set by setLimit. After this call no limit checking will be made on any read until a setLimit()) call is made.
        Specified by:
        clearLimit in interface Limit
        Returns:
        the number of bytes within the limit that have not been read or written.