This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes How to store StringBuffer contents into a blob? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to store StringBuffer contents into a blob?" Watch "How to store StringBuffer contents into a blob?" New topic
Author

How to store StringBuffer contents into a blob?

Abhi Basu
Greenhorn

Joined: Apr 05, 2004
Posts: 13
I want to store the blob into a db table after this is accomplished.

Thanks!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30789
    
157

Abhi,
The StringBuffer can be converted into a string which can be converted into a blob. The constructor for the blob is database specific.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Abhi Basu
Greenhorn

Joined: Apr 05, 2004
Posts: 13
sbFinal is the StringBuffer with all the data.

BLOB oracleBlob = null;
OutputStream outstream = ((BLOB)oracleBlob).getBinaryOutputStream();
byte[] data = sbFinal.toString().getBytes();
outstream.write(data);
outstream.close();

Is this how to do it for an Oracle blob? Thanks.
[ May 21, 2004: Message edited by: Abhi Basu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to store StringBuffer contents into a blob?