Package org.firebirdsql.jdbc
Class FBBlobInputStream
- java.lang.Object
- 
- java.io.InputStream
- 
- org.firebirdsql.jdbc.FBBlobInputStream
 
 
- 
- All Implemented Interfaces:
- java.io.Closeable,- java.lang.AutoCloseable,- FirebirdBlob.BlobInputStream
 
 public final class FBBlobInputStream extends java.io.InputStream implements FirebirdBlob.BlobInputStream An input stream for reading directly from a FBBlob instance.
- 
- 
Field Summary- 
Fields inherited from interface org.firebirdsql.jdbc.FirebirdBlob.BlobInputStreamSEEK_MODE_ABSOLUTE, SEEK_MODE_FROM_TAIL, SEEK_MODE_RELATIVE
 
- 
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Get number of available bytes that can be read without blocking.voidclose()Close this stream.FirebirdBlobgetBlob()Get instance ofFirebirdBlobto which this stream belongs to.longlength()Get Blob length.intread()Read a single byte from the stream.intread(byte[] b, int off, int len)Read some bytes from the stream intobuffer.voidreadFully(byte[] b)Readbuffer.lengthbytes from the buffer.voidreadFully(byte[] b, int off, int len)Readlengthfrom the stream into the specified buffer.intreadNBytes(byte[] b, int off, int len)Similar to Java 9'sInputStream#readNBytes(byte[], int, int)byte[]readNBytes(int len)Similar to Java 9'sInputStream#readNBytes(int).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)longtransferTo(java.io.OutputStream out)
 
- 
- 
- 
Method Detail- 
getBlobpublic FirebirdBlob 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 interface- FirebirdBlob.BlobInputStream
- Returns:
- instance of FirebirdBlob.
 
 - 
seekpublic void seek(int position) throws java.io.IOExceptionDescription 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 interface- FirebirdBlob.BlobInputStream
- Parameters:
- position- absolute position to seek, starting position is 0 (note, in- Blob.getBytes(long, int)starting position is 1).
- Throws:
- java.io.IOException- if I/O error occurs.
 
 - 
seekpublic void seek(int position, int seekMode) throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamMove current position in the Blob stream. Depending on the specified seek mode, position can be either positive or negative.- Specified by:
- seekin interface- FirebirdBlob.BlobInputStream
- Parameters:
- position- position in the stream, starting position is 0 (note, in- Blob.getBytes(long, int)starting position is 1)
- seekMode- mode of seek operation, one of- FirebirdBlob.BlobInputStream.SEEK_MODE_ABSOLUTE,- FirebirdBlob.BlobInputStream.SEEK_MODE_RELATIVEor- FirebirdBlob.BlobInputStream.SEEK_MODE_FROM_TAIL
- Throws:
- java.io.IOException- if I/O error occurs
 
 - 
seekpublic void seek(int position, FbBlob.SeekMode seekMode) throws java.io.IOException- Throws:
- java.io.IOException
 
 - 
lengthpublic long length() throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamGet Blob length. This is a shortcut forinputStream.getBlob().length()call, and is more resource friendly, because no new Blob handle is created.- Specified by:
- lengthin interface- FirebirdBlob.BlobInputStream
- Returns:
- length of the blob
- Throws:
- java.io.IOException- if I/O error occurs
 
 - 
availablepublic int available() throws java.io.IOExceptionDescription 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 interface- FirebirdBlob.BlobInputStream
- Overrides:
- availablein 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.
 
 - 
readpublic int read() throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamRead a single byte from the stream.- Specified by:
- readin interface- FirebirdBlob.BlobInputStream
- Specified by:
- readin class- java.io.InputStream
- Returns:
- next byte read from the stream or -1if end of stream was reached
- Throws:
- java.io.IOException- if I/O error occurs
- See Also:
- InputStream.read()
 
 - 
readpublic int read(byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamRead some bytes from the stream intobuffer.The implementation may read less bytes than requested. Implementations may perform multiple roundtrips to the server to fill bufferup to the requested length.- Specified by:
- readin interface- FirebirdBlob.BlobInputStream
- Overrides:
- readin 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 0iflen == 0,-1if 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)
 
 - 
readNBytespublic int readNBytes(byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamSimilar to Java 9'sInputStream#readNBytes(byte[], int, int)- Specified by:
- readNBytesin interface- FirebirdBlob.BlobInputStream
- Overrides:
- readNBytesin class- java.io.InputStream
- Throws:
- java.io.IOException
 
 - 
readNBytespublic byte[] readNBytes(int len) throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamSimilar to Java 9'sInputStream#readNBytes(int).- Specified by:
- readNBytesin interface- FirebirdBlob.BlobInputStream
- Overrides:
- readNBytesin class- java.io.InputStream
- Throws:
- java.io.IOException
 
 - 
readFullypublic void readFully(byte[] b, int off, int len) throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamReadlengthfrom the stream into the specified buffer.This method will throw an EOFExceptionif end-of-blob was reached before readinglengthbytes.- Specified by:
- readFullyin 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.
 
 - 
readFullypublic void readFully(byte[] b) throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamReadbuffer.lengthbytes from the buffer. This is a shortcut method forreadFully(buffer, 0, buffer.length)call.- Specified by:
- readFullyin interface- FirebirdBlob.BlobInputStream
- Parameters:
- b- buffer where data should be read
- Throws:
- java.io.IOException- if I/O error occurs
 
 - 
transferTopublic long transferTo(java.io.OutputStream out) throws java.io.IOException- Overrides:
- transferToin class- java.io.InputStream
- Throws:
- java.io.IOException
 
 - 
closepublic void close() throws java.io.IOExceptionDescription copied from interface:FirebirdBlob.BlobInputStreamClose this stream.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- java.io.Closeable
- Specified by:
- closein interface- FirebirdBlob.BlobInputStream
- Overrides:
- closein class- java.io.InputStream
- Throws:
- java.io.IOException- if I/O error occurs.
 
 
- 
 
-