File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30361
    
150

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?