Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blob to pdf

Status
Not open for further replies.

dragon2733

Programmer
Mar 24, 2006
4
US
I need to read a blob from the oracle database and display it as a PDF. I have included the code I am using, however, I am getting a nullpointer exception when trying to write the blob. What am I missing? Is there a better way to do this? Thanks!

InputStream inStrm = null;
OutputStream outStrm = null;

Blob custBlob = pdfBlob.getBlob(); // get blob from db
inStrm = custBlob.getBinaryStream();
byte[] bytes = new byte[(int)custBlob.length()];

inStrm.read(bytes);

outStrm.write(bytes);

outStrm.flush();
outStrm.close();
inStrm.close();



 
Is the blob actually a PDF ?

Which line causes the NPE ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
The blob is a PDFStream.
The npe occurs on outStrm.write(bytes);

 
So is 'outStrm' null or is 'bytes' null ?

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
so you need to create your outStrm object then ...

--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
Just reading through the code you will see that you declare the OutputStream object without initializing it.

Cheers,
Dian
 
Thanks! I have been looking at it so long I don't see things that I should.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top