Interface Blob

  • All Known Subinterfaces:
    MemoryBlob, OverflowableBlob, WritableBlob
    All Known Implementing Classes:
    AbstractWritableBlob

    public interface Blob
    Stores binary data.

    Blobs are thread safe in the sense that methods defined by this interface may be called concurrently. In addition, two different threads can safely invoke methods on two different InputStream instances retrieved by getInputStream() concurrently. However some blobs (in particular WritableBlob implementations) may define additional methods and invoking these methods concurrently with methods defined by this interface is generally not thread safe.

    • Method Detail

      • getInputStream

        InputStream getInputStream()
                            throws IOException
        Get an input stream to read the data in the blob. A new InputStream object is returned each time this method is called, and the stream is positioned at the beginning of the data.
        Returns:
        the input stream to read the data from
        Throws:
        IOException
      • writeTo

        void writeTo​(OutputStream out)
              throws StreamCopyException
        Write the data to a given output stream. This method can be called multiple times, i.e. it doesn't consume the content.
        Parameters:
        out - The output stream to write the data to. This method will not close the stream.
        Throws:
        StreamCopyException - Thrown if there is an I/O when reading the data from the blob or when writing it to the stream. StreamCopyException.getOperation() can be used to determine whether the failed operation was a read or a write.
      • getSize

        long getSize()
        Get the size of the blob.
        Returns:
        the number of bytes in the blob