Class FBBlobInputStream

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Get number of available bytes that can be read without blocking.
      void close()
      Close this stream.
      FirebirdBlob getBlob()
      Get instance of FirebirdBlob to which this stream belongs to.
      long length()
      Get Blob length.
      int read()
      Read a single byte from the stream.
      int read​(byte[] b, int off, int len)
      Read some bytes from the stream into buffer.
      void readFully​(byte[] b)
      Read buffer.length bytes from the buffer.
      void readFully​(byte[] b, int off, int len)
      Read length from the stream into the specified buffer.
      int readNBytes​(byte[] b, int off, int len)
      Similar to Java 9's InputStream#readNBytes(byte[], int, int)
      byte[] readNBytes​(int len)
      Similar to Java 9's InputStream#readNBytes(int).
      void seek​(int position)
      Move current position in the Blob stream.
      void seek​(int position, int seekMode)
      Move current position in the Blob stream.
      void seek​(int position, FbBlob.SeekMode seekMode)  
      long transferTo​(java.io.OutputStream out)  
      • Methods inherited from class java.io.InputStream

        mark, markSupported, nullInputStream, read, readAllBytes, reset, skip
      • Methods inherited from class java.lang.Object

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

      • seek

        public void seek​(int position,
                         FbBlob.SeekMode seekMode)
                  throws java.io.IOException
        Throws:
        java.io.IOException
      • length

        public long length()
                    throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Get Blob length. This is a shortcut for inputStream.getBlob().length() call, and is more resource friendly, because no new Blob handle is created.
        Specified by:
        length in interface FirebirdBlob.BlobInputStream
        Returns:
        length of the blob
        Throws:
        java.io.IOException - if I/O error occurs
      • available

        public int available()
                      throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Get number of available bytes that can be read without blocking. This method will return number of bytes of the last read blob segment in the blob buffer.
        Specified by:
        available in interface FirebirdBlob.BlobInputStream
        Overrides:
        available in class java.io.InputStream
        Returns:
        number of bytes available without blocking or -1 if end of stream is reached.
        Throws:
        java.io.IOException - if I/O error occurred.
      • read

        public int read()
                 throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Read a single byte from the stream.
        Specified by:
        read in interface FirebirdBlob.BlobInputStream
        Specified by:
        read in class java.io.InputStream
        Returns:
        next byte read from the stream or -1 if end of stream was reached
        Throws:
        java.io.IOException - if I/O error occurs
        See Also:
        InputStream.read()
      • read

        public int read​(byte[] b,
                        int off,
                        int len)
                 throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Read some bytes from the stream into buffer.

        The implementation may read less bytes than requested. Implementations may perform multiple roundtrips to the server to fill buffer up to the requested length.

        Specified by:
        read in interface FirebirdBlob.BlobInputStream
        Overrides:
        read in class java.io.InputStream
        Parameters:
        b - buffer into which data should be read
        off - offset in the buffer where to start
        len - number of bytes to read
        Returns:
        number of bytes that were actually read, returns 0 if len == 0, -1 if end-of-blob was reached without reading any bytes
        Throws:
        java.io.IOException - if I/O error occurs
        See Also:
        InputStream.read(byte[], int, int)
      • readNBytes

        public int readNBytes​(byte[] b,
                              int off,
                              int len)
                       throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Similar to Java 9's InputStream#readNBytes(byte[], int, int)
        Specified by:
        readNBytes in interface FirebirdBlob.BlobInputStream
        Overrides:
        readNBytes in class java.io.InputStream
        Throws:
        java.io.IOException
      • readNBytes

        public byte[] readNBytes​(int len)
                          throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Similar to Java 9's InputStream#readNBytes(int).
        Specified by:
        readNBytes in interface FirebirdBlob.BlobInputStream
        Overrides:
        readNBytes in class java.io.InputStream
        Throws:
        java.io.IOException
      • readFully

        public void readFully​(byte[] b,
                              int off,
                              int len)
                       throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Read length from the stream into the specified buffer.

        This method will throw an EOFException if end-of-blob was reached before reading length bytes.

        Specified by:
        readFully in interface FirebirdBlob.BlobInputStream
        Parameters:
        b - buffer where data should be read
        off - offset in the buffer where to start
        len - number of bytes to read
        Throws:
        java.io.EOFException - if stream end was reached when reading data.
        java.io.IOException - if I/O error occurs.
      • readFully

        public void readFully​(byte[] b)
                       throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Read buffer.length bytes from the buffer. This is a shortcut method for readFully(buffer, 0, buffer.length) call.
        Specified by:
        readFully in interface FirebirdBlob.BlobInputStream
        Parameters:
        b - buffer where data should be read
        Throws:
        java.io.IOException - if I/O error occurs
      • transferTo

        public long transferTo​(java.io.OutputStream out)
                        throws java.io.IOException
        Overrides:
        transferTo in class java.io.InputStream
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Description copied from interface: FirebirdBlob.BlobInputStream
        Close this stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in interface FirebirdBlob.BlobInputStream
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.IOException - if I/O error occurs.