Top Description Inners Fields Constructors Methods
org.hsqldb.jdbc

public Class JDBCBlobFile

extends Object
implements Blob
Class Inheritance
All Implemented Interfaces
java.sql.Blob, java.lang.AutoCloseable
Imports
java.io.BufferedInputStream, .BufferedOutputStream, .ByteArrayOutputStream, .File, .FileInputStream, .IOException, .InputStream, .OutputStream, .RandomAccessFile, .Reader, .Writer, java.sql.Blob, .SQLException, java.util.ArrayList, .Iterator, .List, org.hsqldb.error.ErrorCode, org.hsqldb.lib.CountdownInputStream, .FileUtil, .FrameworkLogger, .InOutUtil, .KMPSearchAlgorithm

A client-side file-based implementation of Blob.

HSQLDB-Specific Information:

Starting with 2.1, in addition to HSQLDB driver support for both client-side in-memory and remote SQL CLOB data implementations, this class is provided to expose efficient, relatively high-performance BLOB operations over client accessible files.

Design Notes

Although it is possible to implement a transactional version of this class, the present implementation directly propagates changes to the underlying file such that changes become visible as soon as they are either implicitly or explicitly flushed to disk.

Author
Campbell Burnet (campbell-burnet@users dot sourceforge.net)
Since
HSQLDB 2.1
Version
2.7.3

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
protected static class

Field Summary

Modifier and TypeField and Description
private static final FrameworkLogger
private boolean
private boolean
private final File
private List<Object>
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public
JDBCBlobFile()

Convenience constructor; equivalent to JDBCBlobFile(true);

public
JDBCBlobFile(boolean
Assigns whether an attempt to delete the backing file is to be made in response to invocation of free().
deleteOnFree
)

Constructs a new instance backed by a File object created in response to invoking File.createTempFile(TEMP_FILE_PREFIX,TEMP_FILE_SUFFIX).

public
JDBCBlobFile(final File
used to back this BLOB instance.
file
)

Convenience constructor; equivalent to JDBCBlobFile(file, false);

public
JDBCBlobFile(final File
used to back this BLOB instance.
file
,
boolean
Assigns whether an attempt to delete the backing file is to be made in response to invocation of free().
deleteOnFree
)

Constructs a new instance backed by the given File object.

Method Summary

Modifier and TypeMethod and Description
private void
protected final void
checkIsFile(boolean checkExists)

private static void
private static void
private static void
private static void
private static void
private void
private void
public synchronized void
free()

Implements java.sql.Blob.free.

This method frees the Blob object and releases the resources that it holds.

public InputStream

Returns:

a stream containing the BLOB data
getBinaryStream
()

Implements java.sql.Blob.getBinaryStream.

Retrieves the BLOB value designated by this Blob instance as a stream.

public InputStream

Returns:

InputStream through which the partial Blob value can be read.
getBinaryStream
(final long
the offset to the first byte of the partial value to be retrieved. The first byte in the Blob is at position 1
pos
,
final long
the length in bytes of the partial value to be retrieved
length
)

Implements java.sql.Blob.getBinaryStream.

Returns an InputStream object that contains a partial Blob value, starting with the byte specified by pos, which is length bytes in length.

public byte[]

Returns:

a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos
getBytes
(final long
the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1
pos
,
final int
the number of consecutive bytes to be copied; the value for length must be 0 or greater
length
)

Implements java.sql.Blob.getBytes.

Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes.

public File

Returns:

the file that backs this BLOB.
getFile
()

Retrieves the canonical File object denoting the file that backs this BLOB.

public boolean

Returns:

true if backing file deletion is attempted; otherwise false.
isDeleteOnFree
()

Retrieves whether an attempt to delete the backing file is made in response to invocation of free().

public long

Returns:

length of the BLOB in bytes
length
()

Implements java.sql.Blob.length.

Returns the number of bytes in the BLOB value designated by this Blob object.

public long

Returns:

the position at which the pattern appears, else -1
position
(final byte[]
the byte array for which to search
pattern
,
final long
the position at which to begin searching; the first position is 1
start
)

Implements java.sql.Blob.position.

Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents.

public long

Returns:

the position at which the pattern begins, else -1
position
(final Blob
the Blob object designating the BLOB value for which to search
pattern
,
final long
the position in the BLOB value at which to begin searching; the first position is 1
start
)

Implements java.sql.Blob.position.

Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins.

private long
position0(final byte[] pattern, final long start)

public OutputStream

Returns:

a java.io.OutputStream object to which data can be written
setBinaryStream
(final long
the position in the BLOB value at which to start writing; the first position is 1
pos
)

Implements java.sql.Blob.setBinaryStream.

Retrieves a stream that can be used to write to the BLOB value that this Blob object represents.

public int

Returns:

the number of bytes written
setBytes
(final long
the position in the BLOB object at which to start writing; the first position is 1
pos
,
final byte[]
the array of bytes to be written to the BLOB value that this Blob object represents
bytes
)

Implements java.sql.Blob.setBytes.

Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written.

public int

Returns:

the number of bytes written
setBytes
(final long
the position in the BLOB object at which to start writing; the first position is 1
pos
,
final byte[]
the array of bytes to be written to this BLOB object
bytes
,
final int
the offset into the array bytes at which to start reading the bytes to be set
offset
,
final int
the number of bytes to be written to the BLOB value from the array of bytes bytes
len
)

Implements java.sql.Blob.setBytes.

Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written.

public void
setDeleteOnFree(boolean
the new value to assign
deleteOnFree
)

Assigns whether an attempt to delete the backing file is made in response to invocation of free().

public void
truncate(long
the length, in bytes, to which the BLOB value that this Blob object represents should be truncated
len
)

Implements java.sql.Blob.truncate.

Truncates the BLOB value that this Blob object represents to be len bytes in length.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final FrameworkLogger LOG
m_closedback to summary
private boolean m_closed
m_deleteOnFreeback to summary
private boolean m_deleteOnFree
m_fileback to summary
private final File m_file
m_streamsback to summary
private List<Object> m_streams
TEMP_FILE_PREFIXback to summary
public static final String TEMP_FILE_PREFIX
TEMP_FILE_SUFFIXback to summary
public static final String TEMP_FILE_SUFFIX

Constructor Detail

JDBCBlobFileback to summary
public JDBCBlobFile() throws SQLException

Convenience constructor; equivalent to JDBCBlobFile(true);

Exceptions
SQLException:
If a file could not be created or if a security manager exists and its {@link java.lang.SecurityManager#checkWrite(java.lang.String)} method does not allow a file to be created.
JDBCBlobFileback to summary
public JDBCBlobFile(boolean deleteOnFree) throws SQLException

Constructs a new instance backed by a File object created in response to invoking File.createTempFile(TEMP_FILE_PREFIX,TEMP_FILE_SUFFIX).

Parameters
deleteOnFree:boolean

Assigns whether an attempt to delete the backing file is to be made in response to invocation of free().

Exceptions
SQLException:
If a file could not be created or if a security manager exists and its {@link java.lang.SecurityManager#checkWrite(java.lang.String)} method does not allow a file to be created.
JDBCBlobFileback to summary
public JDBCBlobFile(final File file) throws SQLException

Convenience constructor; equivalent to JDBCBlobFile(file, false);

Parameters
file:File

used to back this BLOB instance.

Exceptions
SQLException:
If an I/O error occurs, which is possible because the construction of the canonical pathname may require file system queries; if a required system property value cannot be accessed, or if a security manager exists and its {@link java.lang.SecurityManager#checkRead} method denies read access to the file
JDBCBlobFileback to summary
public JDBCBlobFile(final File file, boolean deleteOnFree) throws SQLException

Constructs a new instance backed by the given File object.

Parameters
file:File

used to back this BLOB instance.

deleteOnFree:boolean

Assigns whether an attempt to delete the backing file is to be made in response to invocation of free().

Exceptions
SQLException:
If an I/O error occurs, which is possible because the construction of the canonical pathname may require file system queries; if a required system property value cannot be accessed, or if a security manager exists and its {@link java.lang.SecurityManager#checkRead} method denies read access to the file

Method Detail

checkClosedback to summary
private void checkClosed() throws SQLException
checkIsFileback to summary
protected final void checkIsFile(boolean checkExists) throws SQLException
closeSafelyback to summary
private static void closeSafely(RandomAccessFile target)
closeSafelyback to summary
private static void closeSafely(InputStream target)
closeSafelyback to summary
private static void closeSafely(OutputStream target)
closeSafelyback to summary
private static void closeSafely(Reader target)
closeSafelyback to summary
private static void closeSafely(Writer target)
closeSafelyback to summary
private void closeSafely(Object target)
createFileback to summary
private void createFile() throws SQLException
freeback to summary
public synchronized void free() throws SQLException

Implements java.sql.Blob.free.

This method frees the Blob object and releases the resources that it holds. The object is invalid once the free method is called.

After free has been called, any attempt to invoke a method other than free will result in a SQLException being thrown. If free is called multiple times, the subsequent calls to free are treated as a no-op.

HSQLDB-Specific Information:

This operation closes any input and/or output streams obtained via getBinaryStream(), getBinaryStream(long, long) or setBinaryStream(long).

Additionally, if the property isDeleteOnFree() is true, then an attempt is made to delete the backing file.

Exceptions
SQLException:
if an error occurs releasing the Blob's resources
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.6
See Also
setDeleteOnFree(boolean), isDeleteOnFree()
getBinaryStreamback to summary
public InputStream getBinaryStream() throws SQLException

Implements java.sql.Blob.getBinaryStream.

Retrieves the BLOB value designated by this Blob instance as a stream.

Returns:InputStream

a stream containing the BLOB data

Exceptions
SQLException:
if there is an error accessing the BLOB value
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.2
See Also
setBinaryStream
getBinaryStreamback to summary
public InputStream getBinaryStream(final long pos, final long length) throws SQLException

Implements java.sql.Blob.getBinaryStream.

Returns an InputStream object that contains a partial Blob value, starting with the byte specified by pos, which is length bytes in length.

Parameters
pos:long

the offset to the first byte of the partial value to be retrieved. The first byte in the Blob is at position 1

length:long

the length in bytes of the partial value to be retrieved

Returns:InputStream

InputStream through which the partial Blob value can be read.

Exceptions
SQLException:
if pos is less than 1 or if pos is greater than the number of bytes in the Blob or if pos + length is greater than the number of bytes in the Blob
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.6
getBytesback to summary
public byte[] getBytes(final long pos, final int length) throws SQLException

Implements java.sql.Blob.getBytes.

Retrieves all or part of the BLOB value that this Blob object represents, as an array of bytes. This byte array contains up to length consecutive bytes starting at position pos.

Parameters
pos:long

the ordinal position of the first byte in the BLOB value to be extracted; the first byte is at position 1

length:int

the number of consecutive bytes to be copied; the value for length must be 0 or greater

Returns:byte[]

a byte array containing up to length consecutive bytes from the BLOB value designated by this Blob object, starting with the byte at position pos

Exceptions
SQLException:
if there is an error accessing the BLOB value; if pos is less than 1 or length is less than 0
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.2
See Also
setBytes
getFileback to summary
public File getFile()

Retrieves the canonical File object denoting the file that backs this BLOB.

Returns:File

the file that backs this BLOB.

isDeleteOnFreeback to summary
public boolean isDeleteOnFree()

Retrieves whether an attempt to delete the backing file is made in response to invocation of free().

Returns:boolean

true if backing file deletion is attempted; otherwise false.

lengthback to summary
public long length() throws SQLException

Implements java.sql.Blob.length.

Returns the number of bytes in the BLOB value designated by this Blob object.

Returns:long

length of the BLOB in bytes

Exceptions
SQLException:
if there is an error accessing the length of the BLOB
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.2
positionback to summary
public long position(final byte[] pattern, final long start) throws SQLException

Implements java.sql.Blob.position.

Retrieves the byte position at which the specified byte array pattern begins within the BLOB value that this Blob object represents. The search for pattern begins at position start.

Parameters
pattern:byte[]

the byte array for which to search

start:long

the position at which to begin searching; the first position is 1

Returns:long

the position at which the pattern appears, else -1

Exceptions
SQLException:
if there is an error accessing the BLOB or if start is less than 1
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.2
positionback to summary
public long position(final Blob pattern, final long start) throws SQLException

Implements java.sql.Blob.position.

Retrieves the byte position in the BLOB value designated by this Blob object at which pattern begins. The search begins at position start.

Parameters
pattern:Blob

the Blob object designating the BLOB value for which to search

start:long

the position in the BLOB value at which to begin searching; the first position is 1

Returns:long

the position at which the pattern begins, else -1

Exceptions
SQLException:
if there is an error accessing the BLOB value or if start is less than 1
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.2
position0back to summary
private long position0(final byte[] pattern, final long start) throws SQLException
setBinaryStreamback to summary
public OutputStream setBinaryStream(final long pos) throws SQLException

Implements java.sql.Blob.setBinaryStream.

Retrieves a stream that can be used to write to the BLOB value that this Blob object represents. The stream begins at position pos. The bytes written to the stream will overwrite the existing bytes in the Blob object starting at the position pos. If the end of the Blob value is reached while writing to the stream, then the length of the Blob value will be increased to accommodate the extra bytes.

Note

If the value specified for pos is greater than the length+1 of the BLOB value then the behavior is undefined. Some JDBC drivers may throw a SQLException while other drivers may support this operation.

HSQLDB-Specific Information:

Data written to the returned stream affects only the content of the underlying file; it has no effect upon a value stored in a database. To propagate the updated Blob value to a database, it is required to supply the Blob instance to an updating or inserting setXXX method of a Prepared or Callable Statement, or to supply the Blob instance to an updateXXX method of an updateable ResultSet.
Parameters
pos:long

the position in the BLOB value at which to start writing; the first position is 1

Returns:OutputStream

a java.io.OutputStream object to which data can be written

Exceptions
SQLException:
if there is an error accessing the BLOB value or if pos is less than 1
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.4
See Also
getBinaryStream
setBytesback to summary
public int setBytes(final long pos, final byte[] bytes) throws SQLException

Implements java.sql.Blob.setBytes.

Writes the given array of bytes to the BLOB value that this Blob object represents, starting at position pos, and returns the number of bytes written. The array of bytes will overwrite the existing bytes in the Blob object starting at the position pos. If the end of the Blob value is reached while writing the array of bytes, then the length of the Blob value will be increased to accommodate the extra bytes.

Note

If the value specified for pos is greater than the length+1 of the BLOB value then the behavior is undefined. Some JDBC drivers may throw a SQLException while other drivers may support this operation.

HSQLDB-Specific Information:

This operation affects only the content of the underlying file; it has no effect upon a value stored in a database. To propagate the updated Blob value to a database, it is required to supply the Blob instance to an updating or inserting setXXX method of a Prepared or Callable Statement, or to supply the Blob instance to an updateXXX method of an updatable ResultSet.
Parameters
pos:long

the position in the BLOB object at which to start writing; the first position is 1

bytes:byte[]

the array of bytes to be written to the BLOB value that this Blob object represents

Returns:int

the number of bytes written

Exceptions
SQLException:
if there is an error accessing the BLOB value or if pos is less than 1
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.4
See Also
getBytes
setBytesback to summary
public int setBytes(final long pos, final byte[] bytes, final int offset, final int len) throws SQLException

Implements java.sql.Blob.setBytes.

Writes all or part of the given byte array to the BLOB value that this Blob object represents and returns the number of bytes written. Writing starts at position pos in the BLOB value; len bytes from the given byte array are written. The array of bytes will overwrite the existing bytes in the Blob object starting at the position pos. If the end of the Blob value is reached while writing the array of bytes, then the length of the Blob value will be increased to accommodate the extra bytes.

Note

If the value specified for pos is greater than the length+1 of the BLOB value then the behavior is undefined. Some JDBC drivers may throw a SQLException while other drivers may support this operation.

HSQLDB-Specific Information:

This operation affects only the content of the underlying file; it has no effect upon a value stored in a database. To propagate the updated Blob value to a database, it is required to supply the Blob instance to an updating or inserting setXXX method of a Prepared or Callable Statement, or to supply the Blob instance to an updateXXX method of an updatable ResultSet.
Parameters
pos:long

the position in the BLOB object at which to start writing; the first position is 1

bytes:byte[]

the array of bytes to be written to this BLOB object

offset:int

the offset into the array bytes at which to start reading the bytes to be set

len:int

the number of bytes to be written to the BLOB value from the array of bytes bytes

Returns:int

the number of bytes written

Exceptions
SQLException:
if there is an error accessing the BLOB value or if pos is less than 1
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.4
See Also
getBytes
setDeleteOnFreeback to summary
public void setDeleteOnFree(boolean deleteOnFree)

Assigns whether an attempt to delete the backing file is made in response to invocation of free().

Parameters
deleteOnFree:boolean

the new value to assign

truncateback to summary
public void truncate(long len) throws SQLException

Implements java.sql.Blob.truncate.

Truncates the BLOB value that this Blob object represents to be len bytes in length.

Note

If the value specified for pos is greater than the length+1 of the BLOB value then the behavior is undefined. Some JDBC drivers may throw a SQLException while other drivers may support this operation.

HSQLDB-Specific Information:

This operation affects only the length of the underlying file; it has no effect upon a value stored in a database. To propagate the truncated Blob value to a database, it is required to supply the Blob instance to an updating or inserting setXXX method of a Prepared or Callable Statement, or to supply the Blob instance to an updateXXX method of an updatable ResultSet.
Parameters
len:long

the length, in bytes, to which the BLOB value that this Blob object represents should be truncated

Exceptions
SQLException:
if there is an error accessing the BLOB value or if len is less than 0
SQLFeatureNotSupportedException:
if the JDBC driver does not support this method
Since
JDK 1.4
org.hsqldb.jdbc back to summary

pack-priv Class JDBCBlobFile.InputStreamAdapter

extends InputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final CountdownInputStream

Constructor Summary

AccessConstructor and Description
pack-priv
InputStreamAdapter(final File file, final long pos, final long length)

Method Summary

Modifier and TypeMethod and Description
public int
available()

Overrides java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected.

public void
close()

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Closes this input stream and releases any system resources associated with the stream.

public int
read()

Implements abstract java.io.InputStream.read.

Reads the next byte of data from the input stream.

public int
read(byte[] b)

Overrides java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b.

public int
read(byte[] b, int off, int len)

Overrides java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes.

public long
skip(long n)

Overrides java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream.

Inherited from java.io.InputStream:
markmarkSupportednullInputStreamreadAllBytesreadNBytesreadNBytesresetskipNBytestransferTo

Field Detail

m_ciStreamback to summary
private final CountdownInputStream m_ciStream

Constructor Detail

InputStreamAdapterback to summary
pack-priv InputStreamAdapter(final File file, final long pos, final long length) throws IOException, SecurityException, NullPointerException, IllegalArgumentException

Method Detail

availableback to summary
public int available() throws IOException

Overrides java.io.InputStream.available.

Doc from java.io.InputStream.available.

Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.

Note that while some implementations of InputStream will return the total number of bytes in the stream, many will not. It is never correct to use the return value of this method to allocate a buffer intended to hold all data in this stream.

A subclass's implementation of this method may choose to throw an IOException if this input stream has been closed by invoking the close() method.

Exceptions
IOException:
if an I/O error occurs.
closeback to summary
public void close() throws IOException

Overrides java.io.InputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.InputStream.close.

Closes this input stream and releases any system resources associated with the stream.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read() throws IOException

Implements abstract java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads some number of bytes from the input stream and stores them into the buffer array b. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.

If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at the end of the file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[0], the next one into b[1], and so on. The number of bytes read is, at most, equal to the length of b. Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1], leaving elements b[k] through b[b.length-1] unaffected.

Exceptions
IOException:
If the first byte cannot be read for any reason other than the end of the file, if the input stream has been closed, or if some other I/O error occurs.
readback to summary
public int read(byte[] b, int off, int len) throws IOException

Overrides java.io.InputStream.read.

Doc from java.io.InputStream.read.

Reads up to len bytes of data from the input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.

This method blocks until input data is available, end of file is detected, or an exception is thrown.

If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b.

The first byte read is stored into element b[off], the next one into b[off+1], and so on. The number of bytes read is, at most, equal to len. Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+k-1], leaving elements b[off+k] through b[off+len-1] unaffected.

In every case, elements b[0] through b[off-1] and elements b[off+len] through b[b.length-1] are unaffected.

Exceptions
IOException:
If the first byte cannot be read for any reason other than end of file, or if the input stream has been closed, or if some other I/O error occurs.
skipback to summary
public long skip(long n) throws IOException

Overrides java.io.InputStream.skip.

Doc from java.io.InputStream.skip.

Skips over and discards n bytes of data from this input stream. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If n is negative, the skip method for class InputStream always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.

Exceptions
IOException:
if an I/O error occurs.
org.hsqldb.jdbc back to summary

protected Class JDBCBlobFile.OutputStreamAdapter

extends OutputStream
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final RandomAccessFile

Constructor Summary

AccessConstructor and Description
protected
OutputStreamAdapter(final File file, final long pos)

protected

Method Summary

Modifier and TypeMethod and Description
public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.

public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.

public void
write(int b)

Implements abstract java.io.OutputStream.write.

Writes the specified byte to this output stream.

public void
write(byte[] b)

Overrides java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream.

public void
write(byte[] b, int off, int len)

Overrides java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream.

Inherited from java.io.OutputStream:
nullOutputStream

Field Detail

m_randomAccessFileback to summary
private final RandomAccessFile m_randomAccessFile

Constructor Detail

OutputStreamAdapterback to summary
protected OutputStreamAdapter(final File file, final long pos) throws IOException, IllegalArgumentException, NullPointerException, SecurityException
OutputStreamAdapterback to summary
protected OutputStreamAdapter(RandomAccessFile randomAccessFile)

Method Detail

closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Exceptions
IOException:
if an I/O error occurs.
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(int b) throws IOException

Implements abstract java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.

Exceptions
IOException:
if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
writeback to summary
public void write(byte[] b) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes b.length bytes from the specified byte array to this output stream. The general contract for write(b) is that it should have exactly the same effect as the call write(b, 0, b.length).

Exceptions
IOException:
if an I/O error occurs.
writeback to summary
public void write(byte[] b, int off, int len) throws IOException

Overrides java.io.OutputStream.write.

Doc from java.io.OutputStream.write.

Writes len bytes from the specified byte array starting at offset off to this output stream. The general contract for write(b, off, len) is that some of the bytes in the array b are written to the output stream in order; element b[off] is the first byte written and b[off+len-1] is the last byte written by this operation.

If b is null, a NullPointerException is thrown.

If off is negative, or len is negative, or off+len is greater than the length of the array b, then an IndexOutOfBoundsException is thrown.

Exceptions
IOException:
if an I/O error occurs. In particular, an IOException is thrown if the output stream is closed.