67,513
社区成员
发帖
与我相关
我的任务
分享
public void saveFile() {
TabFile tabFile = new TabFile();//自定义的实体类
File file = new File("D://tt.zip");
try {
FileInputStream fis = new FileInputStream(file);
byte[] content = new byte[fis.available()];
fis.read(content);
tabFile.setFiletext(Hibernate.createBlob(content));//获取Blob类型的字段信息
System.out.println("二进制:" + tabFile.getFiletext());
Session session = this.getSessionFactory().getCurrentSession();
session.save(tabFile);
fis.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
//readFile();
}