org.firebirdsql.jdbc

## Class FBBlobOutputStream

- java.lang.Object
- - java.io.OutputStream
  - - org.firebirdsql.jdbc.FBBlobOutputStream

- All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable, FirebirdBlob.BlobOutputStream

      public final class FBBlobOutputStream
      extends java.io.OutputStream
      implements FirebirdBlob.BlobOutputStream

  `OutputStream` for writing Firebird blobs.

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close this stream.
    `void` | `flush()`
    `FirebirdBlob` | `getBlob()` Get instance of `FirebirdBlob` to which this stream belongs to.
    `long` | `length()` Get Blob length.
    `void` | `write(byte[] b, int off, int len)` Write data from the buffer into this stream.
    `void` | `write(int b)` Write single byte into the stream.

    - ### Methods inherited from class java.io.OutputStream

      `write`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### getBlob

          public FirebirdBlob getBlob()

      Description copied from interface: `FirebirdBlob.BlobOutputStream`
      Get instance of `FirebirdBlob` to which this stream belongs to.

      Note, code

           FirebirdBlob.BlobOutputStream otherStream = (FirebirdBlob.BlobOutputStream)
               inputStream.getBlob().setBinaryStream(1);

      will return new stream object.
      Specified by:
        `getBlob` in interface `FirebirdBlob.BlobOutputStream`
      Returns:
        instance of `FirebirdBlob`.

    - #### length

          public long length()
                      throws java.io.IOException

      Description copied from interface: `FirebirdBlob.BlobOutputStream`
      Get Blob length. This method is the only available way to obtain length of a Blob that is in temporary state,
      Specified by:
        `length` in interface `FirebirdBlob.BlobOutputStream`
      Returns:
        length of the blob.
      Throws:
        `java.io.IOException` - if I/O error occurs.

    - #### write

          public void write(int b)
                     throws java.io.IOException

      Write single byte into the stream.

      Writes are buffered up to the buffer length of the blob (optionally specified by the connection property `blobBufferSize`).

      Specified by:
        `write` in interface `FirebirdBlob.BlobOutputStream`
      Specified by:
        `write` in class `java.io.OutputStream`
      Parameters:
        `b` - data to write, only lowest 8 bits are written.
      Throws:
        `java.io.IOException` - if I/O error occurs.

    - #### write

          public void write(byte[] b,
                   int off,
                   int len)
                     throws java.io.IOException

      Write data from the buffer into this stream.

      Writes are buffered up to the buffer length of the blob (optionally specified by the connection property `blobBufferSize`).

      Specified by:
        `write` in interface `FirebirdBlob.BlobOutputStream`
      Overrides:
        `write` in class `java.io.OutputStream`
      Parameters:
        `b` - buffer from which data should be written.
        `off` - offset in the buffer.
        `len` - number of bytes to write.
      Throws:
        `java.io.IOException` - if I/O error occurs.

    - #### flush

          public void flush()
                     throws java.io.IOException

      Specified by:
        `flush` in interface `java.io.Flushable`
      Overrides:
        `flush` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException`

    - #### close

          public void close()
                     throws java.io.IOException

      Description copied from interface: `FirebirdBlob.BlobOutputStream`
      Close this stream. Calling this method closes Blob stream and moves Blob from temporary into permanent state making any further content updates impossible.
      Specified by:
        `close` in interface `java.io.Closeable`
      Specified by:
        `close` in interface `java.lang.AutoCloseable`
      Specified by:
        `close` in interface `FirebirdBlob.BlobOutputStream`
      Overrides:
        `close` in class `java.io.OutputStream`
      Throws:
        `java.io.IOException` - if I/O error occurs.

Copyright © 2001-2021 Jaybird (Firebird JDBC/JCA) team. All rights reserved.