Oracle® interMedia Java Classes Reference 10g Release 1 (10.1) Part Number B10830-01 |
|
|
View PDF |
This section presents reference information on the methods associated with the BlobInputStream object, which provides an interface for JAI to read data from BLOBs. It is a subclass of com.sun.media.jai.codec.SeekableStream and java.io.InputStream; it implements java.io.DataInput.
Before running the methods associated with the BlobInputStream object, the following operations must have already been performed:
The following import statements have been included:
import javax.media.jai.JAI; import java.awt.image.RenderedImage;
A local BlobInputStream object named inStream has been created.
Format
public BlobInputStream(oracle.sql.BLOB blob)
Description
Creates a BlobInputStream object that reads from the specified BLOB. The constructor uses an optimal chunk size that is determined by the database.
Parameters
The BLOB from which data will be read.
Return Value
None.
Exceptions
java.io.IOException
java.sql.SQLException
Examples
None.
Format
public BlobInputStream(oracle.sql.BLOB blob, int chunkSize)
Description
Creates a BlobInputStream object that reads from the specified BLOB. The constructor uses the specified chunk size.
Parameters
The BLOB from which data will be read.
The maximum amount of data to read from the BLOB at one time.
Return Value
None.
Exceptions
java.io.IOException
java.sql.SQLException
Examples
None.
Format
public boolean canSeekBackwards( )
Description
Checks whether or not the stream can read backwards. Because the BlobInputStream object can read backwards, this method will always return true.
Parameters
None.
Return Value
This method returns true.
Exceptions
None.
Examples
None.
Format
public void close( )
Description
Closes the BlobInputStream object, releasing any resources being used.
Parameters
None.
Return Value
None.
Exceptions
java.io.IOException
Examples
None.
Format
public oracle.sql.BLOB getBLOB( )
Description
Returns the BLOB associated with the BlobInputStream object.
Parameters
None.
Return Value
This method returns the BLOB associated with the BlobInputStream object.
Exceptions
None.
Examples
None.
Format
public long getFilePointer( )
Description
Returns the offset from the beginning of the BLOB at which the next read operation will occur.
Parameters
None.
Return Value
This method returns the offset from the beginning of the BLOB at which the next read operation will occur, in bytes.
Exceptions
java.io.IOException
Examples
None.
Format
public void mark(int readLimit)
Description
Marks the current position in the BlobInputStream object. A call to the reset( ) method will return you to the last marked position in the BlobInputStream object.
Parameters
This argument is ignored by the class.
Return Value
None.
Exceptions
None.
Examples
None.
Format
public boolean markSupported( )
Description
Checks whether or not the BlobInputStream object supports marking. Because the BlobInputStream object supports marking, this method will always return true.
Parameters
None.
Return Value
This method returns true.
Exceptions
None.
Examples
None.
Format
public int read( )
Description
Reads a single byte from the BLOB associated with the BlobInputStream object.
Parameters
None.
Return Value
This method returns the byte of data that is read, or -1 if the end of the BLOB has been reached.
Exceptions
java.io.IOException
Examples
None.
Format
public int read(byte[ ] buffer)
Description
Reads data from the BLOB into the specified buffer.
Parameters
The buffer into which the data is read.
Return Value
This method returns the number of bytes read into the buffer, or -1 if the end of the BLOB was reached before any data was read. The value cannot exceed the length of the buffer.
Exceptions
java.io.IOException
Examples
None.
Format
public int read(byte[ ]buffer, int off, int len)
Description
Reads up to the specified length of data from the BLOB into the specified buffer, starting from the specified offset.
Parameters
The buffer into which the data is read.
The offset from the beginning of the buffer at which data will be written, in bytes.
The maximum number of bytes to be written to the buffer.
Return Value
This method returns the number of bytes read into the buffer, or -1 if the end of the BLOB has been reached. The value cannot exceed the length of the buffer.
Exceptions
java.io.IOException
Examples
None.
Format
public long remaining( )
Description
Returns the number of unread bytes remaining in the BLOB.
Parameters
None.
Return Value
This method returns the number of unread bytes in the BLOB.
Exceptions
None.
Examples
None.
Format
public void reset( )
Description
Repositions the stream to the position of the last valid mark.
Parameters
None.
Return Value
None.
Exceptions
java.io.IOException
Examples
None.
Format
public void seek(long pos)
Description
Sets the offset from the beginning of the BLOB at which the next read operation should occur.
Parameters
The offset from the beginning of the BLOB at which the next read operation should occur.
Return Value
None.
Exceptions
java.io.IOException
Examples
None.
Format
public long skip(long n)
Description
Attempts to skip over the specified number of bytes in the BLOB.
The number of bytes skipped may be smaller than the specified number; for example, the number would be smaller if the end of the file is reached.
Parameters
The number of bytes to be skipped.
Return Value
This method returns the number of bytes that are actually skipped.
Exceptions
java.io.IOException
Examples
None.