java.lang.Object
java.io.InputStream
org.firebirdsql.jdbc.FBBlobInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FirebirdBlob.BlobInputStream
@InternalApi
public final class FBBlobInputStream
extends InputStream
implements FirebirdBlob.BlobInputStream
An input stream for reading directly from a FBBlob instance.
This class is internal API of Jaybird. Future versions may radically change, move, or make inaccessible this type.
For the public API, refer to the FirebirdBlob.BlobInputStream
interface.
-
Field Summary
Fields inherited from interface org.firebirdsql.jdbc.FirebirdBlob.BlobInputStream
SEEK_MODE_ABSOLUTE, SEEK_MODE_FROM_TAIL, SEEK_MODE_RELATIVE
-
Method Summary
Modifier and TypeMethodDescriptionint
Get number of available bytes that can be read without blocking.void
close()
Close this stream.getBlob()
Get instance ofFirebirdBlob
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 intobuffer
.void
readFully
(byte[] b) Readbuffer.length
bytes from the buffer.void
readFully
(byte[] b, int off, int len) Readlength
from the stream into the specified buffer.int
readNBytes
(byte[] b, int off, int len) 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
(OutputStream out) Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, reset, skip, skipNBytes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.firebirdsql.jdbc.FirebirdBlob.BlobInputStream
readNBytes
-
Method Details
-
getBlob
Description copied from interface:FirebirdBlob.BlobInputStream
Get instance ofFirebirdBlob
to which this stream belongs to.Note, code
FirebirdBlob.BlobInputStream otherStream = (FirebirdBlob.BlobInputStream) inputStream.getBlob().getBinaryStream();
will return new stream object.- Specified by:
getBlob
in interfaceFirebirdBlob.BlobInputStream
- Returns:
- instance of
FirebirdBlob
.
-
seek
Description copied from interface:FirebirdBlob.BlobInputStream
Move current position in the Blob stream. This is a shortcut method toFirebirdBlob.BlobInputStream.seek(int, int)
passingFirebirdBlob.BlobInputStream.SEEK_MODE_ABSOLUTE
as seek mode.- Specified by:
seek
in interfaceFirebirdBlob.BlobInputStream
- Parameters:
position
- absolute position to seek, starting position is 0 (note, inBlob.getBytes(long, int)
starting position is 1).- Throws:
IOException
- if I/O error occurs.
-
seek
Description copied from interface:FirebirdBlob.BlobInputStream
Move current position in the Blob stream. Depending on the specified seek mode, position can be either positive or negative.- Specified by:
seek
in interfaceFirebirdBlob.BlobInputStream
- Parameters:
position
- position in the stream, starting position is 0 (note, inBlob.getBytes(long, int)
starting position is 1)seekMode
- mode of seek operation, one ofFirebirdBlob.BlobInputStream.SEEK_MODE_ABSOLUTE
,FirebirdBlob.BlobInputStream.SEEK_MODE_RELATIVE
orFirebirdBlob.BlobInputStream.SEEK_MODE_FROM_TAIL
- Throws:
IOException
- if I/O error occurs
-
seek
- Throws:
IOException
-
length
Description copied from interface:FirebirdBlob.BlobInputStream
Get Blob length. This is a shortcut forinputStream.getBlob().length()
call, and is more resource friendly, because no new Blob handle is created.- Specified by:
length
in interfaceFirebirdBlob.BlobInputStream
- Returns:
- length of the blob
- Throws:
IOException
- if I/O error occurs
-
available
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 interfaceFirebirdBlob.BlobInputStream
- Overrides:
available
in classInputStream
- Returns:
- number of bytes available without blocking or -1 if end of stream is reached.
- Throws:
IOException
- if I/O error occurred.
-
read
Description copied from interface:FirebirdBlob.BlobInputStream
Read a single byte from the stream.- Specified by:
read
in interfaceFirebirdBlob.BlobInputStream
- Specified by:
read
in classInputStream
- Returns:
- next byte read from the stream or
-1
if end of stream was reached - Throws:
IOException
- if I/O error occurs- See Also:
-
read
Description copied from interface:FirebirdBlob.BlobInputStream
Read some bytes from the stream intobuffer
.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 interfaceFirebirdBlob.BlobInputStream
- Overrides:
read
in classInputStream
- Parameters:
b
- buffer into which data should be readoff
- offset in the buffer where to startlen
- number of bytes to read- Returns:
- number of bytes that were actually read, returns
0
iflen == 0
,-1
if end-of-blob was reached without reading any bytes - Throws:
IOException
- if I/O error occurs- See Also:
-
readNBytes
- Specified by:
readNBytes
in interfaceFirebirdBlob.BlobInputStream
- Overrides:
readNBytes
in classInputStream
- Throws:
IOException
- See Also:
-
readFully
Description copied from interface:FirebirdBlob.BlobInputStream
Readlength
from the stream into the specified buffer.This method will throw an
EOFException
if end-of-blob was reached before readinglength
bytes.- Specified by:
readFully
in interfaceFirebirdBlob.BlobInputStream
- Parameters:
b
- buffer where data should be readoff
- offset in the buffer where to startlen
- number of bytes to read- Throws:
EOFException
- if stream end was reached when reading data.IOException
- if I/O error occurs.
-
readFully
Description copied from interface:FirebirdBlob.BlobInputStream
Readbuffer.length
bytes from the buffer. This is a shortcut method forreadFully(buffer, 0, buffer.length)
call.- Specified by:
readFully
in interfaceFirebirdBlob.BlobInputStream
- Parameters:
b
- buffer where data should be read- Throws:
IOException
- if I/O error occurs
-
transferTo
- Overrides:
transferTo
in classInputStream
- Throws:
IOException
-
close
Description copied from interface:FirebirdBlob.BlobInputStream
Close this stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFirebirdBlob.BlobInputStream
- Overrides:
close
in classInputStream
- Throws:
IOException
- if I/O error occurs.
-