Blobpublic class Blob extends Object implements Blob
This class is inherited from java.sql.Blob.
The Blob is used to store binary data in and read binary data from the SQLite database.
SystemCapability.Data#DATA_APPDATAMGR| 构造器 | 说明 |
|---|---|
Blob() |
An no-argument constructor used to create a
Blob object. |
Blob(byte[] blob) |
A constructor used to create a
Blob object from data in an array of bytes. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
boolean |
equals(Object object) |
Indicates whether some other object is "equal to" this one.
|
void |
free() |
This method frees the
Blob object and releases the resources that
it holds. |
InputStream |
getBinaryStream() |
Retrieves the
BLOB value designated by this
Blob instance as a stream. |
InputStream |
getBinaryStream(long pos,
long length) |
Returns an
InputStream object that contains a partial Blob value,
starting with the byte specified by pos, which is length bytes in length. |
byte[] |
getBytes(long pos,
int length) |
Retrieves all or part of the
BLOB
value that this Blob object represents, as an array of
bytes. |
int |
hashCode() |
Returns a hash code value for the object.
|
long |
length() |
Returns the number of bytes in the
BLOB value
designated by this Blob object. |
long |
position(byte[] pattern,
long start) |
This method is not supported currently.
|
long |
position(Blob pattern,
long start) |
This method is not supported currently.
|
OutputStream |
setBinaryStream(long indexToWriteAt) |
Retrieves a stream that can be used to write to the
BLOB
value that this Blob object represents. |
int |
setBytes(long writeAt,
byte[] bytes) |
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. |
int |
setBytes(long writeAt,
byte[] bytes,
int offset,
int length) |
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. |
void |
truncate(long len) |
Truncates the
BLOB value that this Blob
object represents to be len bytes in length. |
public Blob()
Blob object.
You can call this method as needed.
public Blob(byte[] blob)
Blob object from data in an array of bytes.blob - Indicates the data in the array of bytes.public long length()
BlobBLOB value
designated by this Blob object.public byte[] getBytes(long pos,
int length)
BlobBLOB
value that this Blob object represents, as an array of
bytes. This byte array contains up to length
consecutive bytes starting at position pos.getBytes 在接口中 Blobpos - the ordinal position of the first byte in the
BLOB value to be extracted; the first byte is at
position 1length - the number of consecutive bytes to be copied; the value
for length must be 0 or greaterlength
consecutive bytes from the BLOB value designated
by this Blob object, starting with the
byte at position posBlob.setBytes(long, byte[])public InputStream getBinaryStream()
BlobBLOB value designated by this
Blob instance as a stream.getBinaryStream 在接口中 BlobBLOB dataBlob.setBinaryStream(long)public long position(byte[] pattern,
long start)
position 在接口中 Blobpattern - the byte array for which to searchstart - the position at which to begin searching; the
first position is 1UnsupportedOperationException - Throws this exception when this method is called.public long position(Blob pattern, long start)
position 在接口中 Blobpattern - the Blob object designating
the BLOB value for which to searchstart - the position in the BLOB value
at which to begin searching; the first position is 1UnsupportedOperationException - Throws this exception when this method is called.public int setBytes(long writeAt,
byte[] bytes)
BlobBLOB 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 then 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.
setBytes 在接口中 BlobwriteAt - the position in the BLOB object at which
to start writing; the first position is 1bytes - the array of bytes to be written to the BLOB
value that this Blob object representsBlob.getBytes(long, int)public int setBytes(long writeAt,
byte[] bytes,
int offset,
int length)
Blobbyte 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 then 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.
setBytes 在接口中 BlobwriteAt - the position in the BLOB object at which
to start writing; the first position is 1bytes - the array of bytes to be written to this BLOB
objectoffset - the offset into the array bytes at which
to start reading the bytes to be setlength - the number of bytes to be written to the BLOB
value from the array of bytes bytesBlob.getBytes(long, int)public OutputStream setBinaryStream(long indexToWriteAt)
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 then 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.
setBinaryStream 在接口中 BlobindexToWriteAt - Indicates the start position. The value ranges from 1 to Integer.MAX_VALUE.java.io.OutputStream object to which data can
be writtenIllegalArgumentException - Throws this exception if the length of the indexToWriteAt value is less
than 1.Blob.getBinaryStream()public void truncate(long len)
BLOB value that this Blob
object represents to be len bytes in length.
Note: If the value specified for pos
is greater then 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.
truncate 在接口中 Bloblen - Indicates the start position. The value ranges from 1 to binary data's length.IllegalArgumentException - Throws this exception if the length of the indexToWriteAt value is less
than 1 or larger than binary data's length.public void free()
BlobBlob 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.
public InputStream getBinaryStream(long pos, long length)
InputStream object that contains a partial Blob value,
starting with the byte specified by pos, which is length bytes in length.getBinaryStream 在接口中 Blobpos - Indicates the start position. The value ranges from 1 to binary data's length.length - the length in bytes of the partial value to be retrievedInputStream through which the partial Blob value can be read.public boolean equals(Object object)
Object
The equals method implements an equivalence relation
on non-null object references:
x, x.equals(x) should return
true.
x and y, x.equals(y)
should return true if and only if
y.equals(x) returns true.
x, y, and z, if
x.equals(y) returns true and
y.equals(z) returns true, then
x.equals(z) should return true.
x and y, multiple invocations of
x.equals(y) consistently return true
or consistently return false, provided no
information used in equals comparisons on the
objects is modified.
x,
x.equals(null) should return false.
The equals method for class Object implements
the most discriminating possible equivalence relation on objects;
that is, for any non-null reference values x and
y, this method returns true if and only
if x and y refer to the same object
(x == y has the value true).
Note that it is generally necessary to override the hashCode
method whenever this method is overridden, so as to maintain the
general contract for the hashCode method, which states
that equal objects must have equal hash codes.
equals 在类中 Objectobject - the reference object with which to compare.true if this object is the same as the obj
argument; false otherwise.Object.hashCode(),
HashMappublic int hashCode()
ObjectHashMap.
The general contract of hashCode is:
hashCode method
must consistently return the same integer, provided no information
used in equals comparisons on the object is modified.
This integer need not remain consistent from one execution of an
application to another execution of the same application.
equals(Object)
method, then calling the hashCode method on each of
the two objects must produce the same integer result.
Object.equals(java.lang.Object)
method, then calling the hashCode method on each of the
two objects must produce distinct integer results. However, the
programmer should be aware that producing distinct integer results
for unequal objects may improve the performance of hash tables.
As much as is reasonably practical, the hashCode method defined by
class Object does return distinct integers for distinct
objects. (This is typically implemented by converting the internal
address of the object into an integer, but this implementation
technique is not required by the
Java™ programming language.)
hashCode 在类中 ObjectObject.equals(java.lang.Object),
System.identityHashCode(java.lang.Object)