Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting a PDF(BLOB) into a BlobDomain and turning it into an InputStream

582466Oct 14 2011 — edited Oct 14 2011
Hello,

I have PDFs stored in a database under the BLOB datatype, and I need to turn it into an InputStream.

I first get the PDF from the database and save it as a BlobDomain.

BlobDomain fileBlobDomain = (BlobDomain)prow.getAttribute("FileData");

Getting the data from the database seems to be successful as when I print fileBlobDomain.getLength(), it returns a real value.

System.out.println("fileBlobDomain size is " + fileBlobDomain.getLength()); --> returns a valid value

However, once I try to get a InputStream from the fileBlobDomain, the InputStream seems to be empty:

InputStream PdfInputStream = fileBlobDomain.getBinaryStream();
System.out.println("available is " + PdfInputStream.available()); --> available is always 0.

Has anyone had similar problems getting PDFs from a database and converting it into an InputStream? I looked everywhere for solutions, but most other solutions seemed to be doing exactly what I was doing above.
I would really appreciate any insight into this problem.

Thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2011
Added on Oct 14 2011
3 comments
438 views