Package org.firebirdsql.jdbc
Class FBBlobInputStream
java.lang.Object
java.io.InputStream
org.firebirdsql.jdbc.FBBlobInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,FirebirdBlob.BlobInputStream
An input stream for reading directly from a FBBlob instance.
-
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 TypeMethodDescriptionintGet number of available bytes that can be read without blocking.voidclose()Close this stream.getBlob()Get instance ofFirebirdBlobto which this stream belongs to.longlength()Get Blob length.intread()Read single byte from the stream.intread(byte[] b, int off, int len) Read some bytes from the stream without blocking.voidreadFully(byte[] b) Readbuffer.lengthbytes from the buffer.voidreadFully(byte[] b, int off, int len) Readlengthfrom the stream into the specified buffer.voidseek(int position) Move current position in the Blob stream.voidseek(int position, int seekMode) Move current position in the Blob stream.voidseek(int position, FbBlob.SeekMode seekMode) Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, readAllBytes, readNBytes, readNBytes, reset, skip, skipNBytes, transferTo
-
Method Details
-
getBlob
Description copied from interface:FirebirdBlob.BlobInputStreamGet instance ofFirebirdBlobto which this stream belongs to.Note, code
FirebirdBlob.BlobInputStream otherStream = (FirebirdBlob.BlobInputStream) inputStream.getBlob().getBinaryStream();will return new stream object.- Specified by:
getBlobin interfaceFirebirdBlob.BlobInputStream- Returns:
- instance of
FirebirdBlob.
-
seek
Description copied from interface:FirebirdBlob.BlobInputStreamMove current position in the Blob stream. This is a shortcut method toFirebirdBlob.BlobInputStream.seek(int, int)passingFirebirdBlob.BlobInputStream.SEEK_MODE_ABSOLUTEas seek mode.- Specified by:
seekin 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.BlobInputStreamMove current position in the Blob stream. Depending on the specified seek mode, position can be either positive or negative.Note, this method allows to move position in the Blob stream only forward. If you need to read data before the current position, new stream must be opened.
- Specified by:
seekin 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_RELATIVEorFirebirdBlob.BlobInputStream.SEEK_MODE_FROM_TAIL.- Throws:
IOException- if I/O erro occurs.
-
seek
- Throws:
IOException
-
length
Description copied from interface:FirebirdBlob.BlobInputStreamGet Blob length. This is shortcut method for theinputStream.getBlob().length()call, however is more resource friendly, because no new Blob handle is created.- Specified by:
lengthin interfaceFirebirdBlob.BlobInputStream- Returns:
- length of the blob.
- Throws:
IOException- if I/O error occurs.
-
available
Description copied from interface:FirebirdBlob.BlobInputStreamGet 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:
availablein interfaceFirebirdBlob.BlobInputStream- Overrides:
availablein classInputStream- Returns:
- number of bytes available without blocking or -1 if end of stream is reached.
- Throws:
IOException- if I/O error occured.
-
read
Description copied from interface:FirebirdBlob.BlobInputStreamRead single byte from the stream.- Specified by:
readin interfaceFirebirdBlob.BlobInputStream- Specified by:
readin classInputStream- Returns:
- next byte read from the stream or -1 if end of stream was reached.
- Throws:
IOException- if I/O error occurs.
-
read
Description copied from interface:FirebirdBlob.BlobInputStreamRead some bytes from the stream without blocking.- Specified by:
readin interfaceFirebirdBlob.BlobInputStream- Overrides:
readin classInputStream- 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 read.
- Throws:
IOException- if I/O error occurs.
-
readFully
Description copied from interface:FirebirdBlob.BlobInputStreamReadlengthfrom the stream into the specified buffer. This method can block until desired number of bytes is read, it can throw an exception if end of stream was reached during read.- Specified by:
readFullyin interfaceFirebirdBlob.BlobInputStream- Parameters:
b- buffer where data should be read.off- offset in the buffer where to start.len- 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.BlobInputStreamReadbuffer.lengthbytes from the buffer. This is a shortcut method forreadFully(buffer, 0, buffer.length)call.- Specified by:
readFullyin interfaceFirebirdBlob.BlobInputStream- Parameters:
b- buffer where data should be read.- Throws:
IOException- if I/O error occurs.
-
close
Description copied from interface:FirebirdBlob.BlobInputStreamClose this stream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceFirebirdBlob.BlobInputStream- Overrides:
closein classInputStream- Throws:
IOException- if I/O error occurs.
-