Read database binary stream to file

	
//Get the binary stream from the result set and convert it to blob
BLOB nFileBLOB = (BLOB) nResultSet.getBlob("FJ");
InputStream nInput = nFileBLOB.getBinaryStream();
//Set the file storage location
String nFileUrl = StringTool.getRandomUUID ();
FileOutputStream nOut = new FileOutputStream(new File("D:\\file upload\\"+nFileUrl));
int len ​​= 0;
byte[] b=new byte[1024];
while((len = nInput.read(b))!=-1){
	nOut.write(b,0,len);
	nOut.close();
	nInput.close();

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326443489&siteId=291194637