blob 转换为byte[]

时间:2014-08-12 18:31:54   收藏:0   阅读:261

 

blob 转换为byte[]

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[],布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!