public interface WritableBlob extends Blob
The behavior of the methods defined by this interface is described in terms of four logical states the blob can be in:
Blob
interface will throw IllegalStateException
if the blob is not in state
COMMITTED.
WritableBlob
instances are generally not thread safe. However, for a blob in state
COMMITTED, all methods defined by the Blob
interface are thread safe.
Modifier and Type | Method and Description |
---|---|
OutputStream |
getOutputStream()
Create an output stream to write data to the blob.
|
long |
readFrom(InputStream in)
Read data from the given input stream and write it to the blob.
|
void |
release()
Release all resources held by this blob.
|
getInputStream, getSize, writeTo
OutputStream getOutputStream() throws IOException
Calls to methods of the returned output stream will modify the state of the blob according to the following rules:
OutputStream.close()
will change the state to COMMITTED.
IOException
if the state is COMMITTED, i.e. if the stream has already been
closed.
The returned stream may implement ReadFromSupport
, especially if the blob stores its
data in memory (in which case ReadFromSupport.readFrom(InputStream, long)
would read
data directly into the buffers managed by the blob).
IllegalStateException
- if the blob is not in state NEWIOException
- if an I/O error occurredlong readFrom(InputStream in) throws StreamCopyException
A call to this method has the same effect as requesting an output stream using
getOutputStream()
and copying the data from the input stream to that
output stream, but the implementation may achieve this result in a more efficient way.
The blob must be in state NEW when this method is called. It will be in state COMMITTED after this method completes successfully.
The method transfers data from the input stream to the blob until the end of the input stream is reached.
in
- An input stream to read data from. This method will not
close the stream.StreamCopyException
IllegalStateException
- if the blob is not in state NEWvoid release() throws IOException
IOException
- if the cleanup could not be completed because an I/O error occurredCopyright © The Apache Software Foundation. All Rights Reserved.