Search code examples
javaswingcastingfirebirdjaybird

org.firebirdsql.jdbc.FBBlob to File


I need to open to user a PDF file which is being saved as a Blob on the firebird database. I tried:

pdf = (File) res.getBlob("blob");
Desktop.getDesktop().open(pdf);

But it does not let me cast blob to file. What would be the ideal way of doing this ?


Solution

  • Use the blob's getBinaryStream() method to read the blob, and write the stream to a File created via createTempFile(). You can then open() the resulting File.