package test.unit.channelinfo;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.sql.Blob;
public class BlobUtil{
public static void ExportBlob(String path,String fileName, Blob myBlob) throws Exception
{
File file=new File(path+"\\"+fileName);
if(!file.exists()){
File binaryFile = new File(path);
if(!binaryFile.exists()){
binaryFile.mkdirs();
}
FileOutputStream outStream = new FileOutputStream(binaryFile+"\\"+fileName);
InputStream inStream = myBlob.getBinaryStream();
int size=(int) myBlob.length();
byte[] buffer = new byte[size];
int length = -1;
while ((length = inStream.read(buffer)) != -1)
{
outStream.write(buffer, 0, length);
outStream.flush();
}
inStream.close();
outStream.close();
}
}
}
将从数据库取出的Blob文件存入硬盘的文件夹中
最新推荐文章于 2024-06-18 16:10:07 发布
