Class PgBufferedOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Direct Known Subclasses:
    GSSOutputStream

    public class PgBufferedOutputStream
    extends java.io.FilterOutputStream
    Buffered output stream. The key difference from BufferedOutputStream is that PgBufferedOutputStream does not perform synchronization. This is an internal class, and it is not meant to be used as a public API.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected byte[] buf
      Buffer for the data
      protected int count
      Number of bytes stored in the buffer
      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      PgBufferedOutputStream​(java.io.OutputStream out, int bufferSize)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void flush()  
      protected void flushBuffer()  
      void write​(byte[] b, int off, int len)  
      void write​(int b)  
      void write​(java.io.InputStream inStream, int remaining)
      Writes the given amount of bytes from an input stream to this buffered stream.
      void writeInt2​(int val)  
      void writeInt4​(int val)  
      void writeZeros​(int len)
      Writes the required number of zero bytes to the output stream.
      • Methods inherited from class java.io.FilterOutputStream

        close, write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

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

      • buf

        protected final byte[] buf
        Buffer for the data
      • count

        protected int count
        Number of bytes stored in the buffer
    • Constructor Detail

      • PgBufferedOutputStream

        public PgBufferedOutputStream​(java.io.OutputStream out,
                                      int bufferSize)
    • Method Detail

      • flushBuffer

        protected void flushBuffer()
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • flush

        public void flush()
                   throws java.io.IOException
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • writeInt2

        public void writeInt2​(int val)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • writeInt4

        public void writeInt4​(int val)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

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

        public void write​(java.io.InputStream inStream,
                          int remaining)
                   throws java.io.IOException
        Writes the given amount of bytes from an input stream to this buffered stream.
        Parameters:
        inStream - input data
        remaining - the number of bytes to transfer
        Throws:
        java.io.IOException - in case writing to the output stream fails
        SourceStreamIOException - in case reading from the source stream fails
      • writeZeros

        public void writeZeros​(int len)
                        throws java.io.IOException
        Writes the required number of zero bytes to the output stream.
        Parameters:
        len - number of bytes to write
        Throws:
        java.io.IOException - in case writing to the underlying stream fails