public final class ByteArrayBlob extends Object implements Blob
BLOB value to an array of bytes.
A ByteArrayBlob contains an internal buffer that contains bytes that may be
read from the stream. The Blob interface provides methods for
getting the length of an SQL BLOB (Binary Large Object) value,
for materializing a BLOB value on the client, and for
determining the position of a pattern of bytes within a BLOB
value. The ByteArrayBlob has static factory methods for constructing an
BLOB using either an existing serializable object, or an array
of bytes. This is a nice way to store serialized objects in a relational
field of type SQL BLOB.| Constructor and Description |
|---|
ByteArrayBlob(byte[] bytes) |
| Modifier and Type | Method and Description |
|---|---|
void |
free() |
InputStream |
getBinaryStream() |
InputStream |
getBinaryStream(long pos,
long length) |
byte[] |
getBytes(long pos,
int length) |
long |
length() |
long |
position(Blob pattern,
long start) |
long |
position(byte[] pattern,
long start) |
OutputStream |
setBinaryStream(long pos) |
int |
setBytes(long pos,
byte[] bytes) |
int |
setBytes(long pos,
byte[] bytes,
int offset,
int length) |
void |
truncate(long length) |
public InputStream getBinaryStream() throws SQLException
getBinaryStream in interface BlobSQLExceptionpublic byte[] getBytes(long pos,
int length)
throws SQLException
getBytes in interface BlobSQLExceptionpublic long length()
throws SQLException
length in interface BlobSQLExceptionpublic long position(Blob pattern, long start) throws SQLException
position in interface BlobSQLExceptionpublic long position(byte[] pattern,
long start)
throws SQLException
position in interface BlobSQLExceptionpublic void free()
throws SQLException
free in interface BlobSQLExceptionpublic InputStream getBinaryStream(long pos, long length) throws SQLException
getBinaryStream in interface BlobSQLExceptionpublic OutputStream setBinaryStream(long pos) throws SQLException
setBinaryStream in interface BlobSQLExceptionpublic int setBytes(long pos,
byte[] bytes)
throws SQLException
setBytes in interface BlobSQLExceptionpublic int setBytes(long pos,
byte[] bytes,
int offset,
int length)
throws SQLException
setBytes in interface BlobSQLExceptionpublic void truncate(long length)
throws SQLException
truncate in interface BlobSQLExceptionCopyright © 2013 JBoss, a division of Red Hat, Inc.. All Rights Reserved.