public byte[] blobToByte(Blob blob) throws Exception {
byte[] bytes = null;
try {
InputStream in=blob.getBinaryStream();
BufferedInputStream inBuffered = new BufferedInputStream(in);
ByteArrayOutputStream out = new ByteArrayOutputStream(1024);
byte[] temp = new byte[1024];
int size = 0;
while ((size = inBuffered.read(temp)) != -1) {
out.write(temp, 0, size);
}
inBuffered.close();
in.close();
bytes = out.toByteArray();
} catch(Exception ex){
ex.printStackTrace();
}
return bytes;
}
blob 转换为byte[]
时间: 2024-11-05 15:52:34