Class Stream

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

    class Stream
    extends java.io.OutputStream
    implements PDFObject
    Represents a stream object in the sense of the PDF specification. The Stream has a defined length.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Stream.Filter  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private boolean closed  
      private java.io.ByteArrayOutputStream data  
      private java.io.OutputStream filteredData  
      private java.util.List<Stream.Filter> filters  
    • Constructor Summary

      Constructors 
      Constructor Description
      Stream​(Stream.Filter... filters)
      Initializes a new Stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()  
      byte[] getContent()
      Returns the content that has been written to this Stream.
      java.util.List<Stream.Filter> getFilters()  
      int getLength()
      Returns the size of the stream contents in bytes.
      private boolean isClosed()  
      void write​(byte[] data)
      Appends the specified byte array to the Stream.
      void write​(int b)  
      • Methods inherited from class java.io.OutputStream

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

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

      • data

        private final java.io.ByteArrayOutputStream data
      • filteredData

        private java.io.OutputStream filteredData
      • closed

        private boolean closed
    • Constructor Detail

      • Stream

        public Stream​(Stream.Filter... filters)
        Initializes a new Stream.
    • Method Detail

      • 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[] data)
                   throws java.io.IOException
        Appends the specified byte array to the Stream.
        Overrides:
        write in class java.io.OutputStream
        Parameters:
        data - Data to be appended.
        Throws:
        java.io.IOException
      • getLength

        public int getLength()
        Returns the size of the stream contents in bytes.
        Returns:
        Number of bytes.
        Throws:
        java.lang.IllegalStateException - if the stream is still open.
      • getContent

        public byte[] getContent()
        Returns the content that has been written to this Stream.
        Returns:
        Stream content.
        Throws:
        java.lang.IllegalStateException - if the stream is still open.
      • isClosed

        private boolean isClosed()
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream