Package org.postgresql.util.internal

# Class PgBufferedOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.postgresql.util.internal.PgBufferedOutputStream

All Implemented Interfaces:
  `Closeable`, `Flushable`, `AutoCloseable`

Direct Known Subclasses:
  `GSSOutputStream`

public class PgBufferedOutputStream extends 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 final 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(OutputStream out, int bufferSize)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `flush()`
  `protected void`
  `flushBuffer()`
  `void`
  `write(byte[] b, int off, int len)`
  `void`
  `write(int b)`
  `void`
  `write(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 Details

  - ### buf

    protected final byte[] buf
    Buffer for the data

  - ### count

    protected int count
    Number of bytes stored in the buffer

- ## Constructor Details

  - ### PgBufferedOutputStream

    public PgBufferedOutputStream(OutputStream out, int bufferSize)

- ## Method Details

  - ### flushBuffer

    protected void flushBuffer() throws IOException
    Throws:
      `IOException`

  - ### flush

    public void flush() throws IOException
    Specified by:
      `flush` in interface `Flushable`
    Overrides:
      `flush` in class `FilterOutputStream`
    Throws:
      `IOException`

  - ### writeInt2

    public void writeInt2(int val) throws IOException
    Throws:
      `IOException`

  - ### writeInt4

    public void writeInt4(int val) throws IOException
    Throws:
      `IOException`

  - ### write

    public void write(int b) throws IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`

  - ### write

    public void write(byte[] b, int off, int len) throws IOException
    Overrides:
      `write` in class `FilterOutputStream`
    Throws:
      `IOException`

  - ### write

    public void write(InputStream inStream, int remaining) throws 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:
      `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 IOException
    Writes the required number of zero bytes to the output stream.
    Parameters:
      `len` - number of bytes to write
    Throws:
      `IOException` - in case writing to the underlying stream fails