/**
* Blob转换为byte[]
* @param blob
* @return
*/
public static byte[] BlobToBytes(Blob blob){
BufferedInputStream bis = null;
try {
bis = new BufferedInputStream(blob.getBinaryStream());
byte[] bytes = new byte[(int) blob.length()];
int len = bytes.length;
int offset = 0;
int read = 0;
while(offset < len && (read = bis.read(bytes, offset, len - offset)) > 0){
offset += read;
}
return bytes;
} catch (SQLException | IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
} finally {
if(bis != null){
try {
bis.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Blob转换为byte[]
最新推荐文章于 2023-07-28 17:41:36 发布