Class BlobOutputStream

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

    public class BlobOutputStream
    extends java.io.OutputStream
    This implements a basic output stream that writes to a LargeObject.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private LargeObject checkClosed()  
      void close()  
      void flush()
      Flushes this output stream and forces any buffered output bytes to be written out.
      private byte[] growBuffer​(int extraBytes)
      Grows an internal buffer to ensure the extra bytes fit in the buffer.
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      • Methods inherited from class java.io.OutputStream

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

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

      • buf

        private byte[] buf
        Buffer.
      • maxBufferSize

        private final int maxBufferSize
        Size of the buffer (default 1K).
      • bufferPosition

        private int bufferPosition
        Position within the buffer.
    • Constructor Detail

      • BlobOutputStream

        public BlobOutputStream​(LargeObject lo)
        Create an OutputStream to a large object.
        Parameters:
        lo - LargeObject
      • BlobOutputStream

        public BlobOutputStream​(LargeObject lo,
                                int bufferSize)
        Create an OutputStream to a large object.
        Parameters:
        lo - LargeObject
        bufferSize - The size of the buffer for single-byte writes
    • Method Detail

      • growBuffer

        private byte[] growBuffer​(int extraBytes)
        Grows an internal buffer to ensure the extra bytes fit in the buffer.
        Parameters:
        extraBytes - the number of extra bytes that should fit in the buffer
        Returns:
        new buffer
      • 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
      • flush

        public void flush()
                   throws java.io.IOException
        Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.OutputStream
        Throws:
        java.io.IOException - if an I/O error occurs.
      • close

        public void close()
                   throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.OutputStream
        Throws:
        java.io.IOException
      • checkClosed

        private LargeObject checkClosed()
                                 throws java.io.IOException
        Throws:
        java.io.IOException