为什么读取照片的时候出错不提示任何出错信息?
@Test
public void TestWriteBlob() throws Exception{
Students s = new Students(1, "张山丰", "男", new Date(), "武当");
File f=new File("C:/Users/Administrator/Pictures/Saved Pictures"+File.separator+"美食.jpg");
//获得该文件的输入流
InputStream input=new FileInputStream(f);//字节流
//创建一个Blob对象
Blob image=Hibernate.getLobCreator(session).createBlob(input, input.available());
//设置照片属性
s.setPicture(image);
//保存
session.save(s);
}
public void TestReadBlob() throws Exception{
System.out.println("11111");
Students s=(Students)session.get(Students.class, 1);
//获得Blob对象
Blob image=s.getPicture();
//获得照片的输入流
InputStream input =image.getBinaryStream();
// System.out.println("input"+input);
//创建输出流
File f=new File("C:"+File.separator+"desc.jpg");
//获得输出流
OutputStream output=new FileOutputStream(f);
//创建缓冲区
byte[] buff=new byte[input.available()];
input.read(buff);//读到缓存区
output.write(buff);
input.close();
output.close();
}