I try to use the blob tutorial and modify it.
I want to test with fileInput
in the bean to create from file, it 's working
public long create()
{
BlobEntity blob = new BlobEntity();
File file = new File("D:\\data.dat");
int fileLength = (int) file.length();
try {
FileInputStream fileinp = new FileInputStream(file);
blob.setBlobby(Hibernate.createBlob(fileinp));
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public InputStream findBlob(long id) throws Exception
{
BlobEntity blob = manager.find(BlobEntity.class, id);
ObjectInputStream ois = new ObjectInputStream(blob.getBlobby().getBinaryStream());
return (InputStream) ois.readObject();
}