//从结果集中获取二进制流转为blob
BLOB nFileBLOB = (BLOB) nResultSet.getBlob("FJ");
InputStream nInput = nFileBLOB.getBinaryStream();
//设置文件存储位置
String nFileUrl=StringTool.getRandomUUID();
FileOutputStream nOut = new FileOutputStream(new File("D:\\文件上传\\"+nFileUrl));
int len=0;
byte[] b=new byte[1024];
while((len = nInput.read(b))!=-1){
nOut.write(b,0,len);
nOut.close();
nInput.close();
读取数据库二进制流转为文件
最新推荐文章于 2024-09-18 13:16:36 发布
本文介绍如何在Java应用程序中处理数据库中的Blob类型数据,包括将其转换为二进制流并保存到指定路径的方法。
2920

被折叠的 条评论
为什么被折叠?



