Home arrow static arrow Java Programming [Archive] - Save Blob into structure of file
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Save Blob into structure of file
This topic has 4 replies on 1 page.

Posts:16
Registered: 6/4/04
Save Blob into structure of file  
Jul 14, 2004 5:33 PM



 
Hi,

I need to overturn the content of a field blob to a structure of file in memory, that is to say, I do not want to keep nothing in the disc.

Since I can do it?
 

Posts:1,125
Registered: 5/4/01
Re: Save Blob into structure of file  
Jul 15, 2004 3:05 AM (reply 1 of 4)



 
Are you a troll with severely bad English?

Also, when you retrieve a blob it IS held in memory. If you dont want it on disk then delete it.

Are you on about database blobs?
 

Posts:16
Registered: 6/4/04
Re: Save Blob into structure of file  
Jul 15, 2004 5:52 AM (reply 2 of 4)



 
Hi,

my English, where is it? ;-)

I have a class with an attribute file, then I want to recover within the attribute file the content of the Blob field.

I am familiarized with Blob, but I do not give with the way to do.

I try this but the FileNotFoudException takes place
          BLOB blob = ((OracleResultSet)resultSet).getBLOB(i++);          File manual = new File( "" ); // simply I want to have the file in memory, nothing but          if (blob!=null) {             InputStream blobStream = blob.getBinaryStream();            FileOutputStream fileOutStream = new FileOutputStream( manual );            byte[] buffer = new byte[10];            int nbytes = 0;            while ( ( nbytes = blobStream.read( buffer ) ) != -1 )              fileOutStream.write( buffer, 0, nbytes );             fileOutStream.flush();            fileOutStream.close();            blobStream.close();          }
 

Posts:65
Registered: 7/28/99
Re: Save Blob into structure of file  
Jul 15, 2004 5:57 AM (reply 3 of 4)



 
Use an ByteArrayOutputStream

Herby
 

Posts:1,125
Registered: 5/4/01
Re: Save Blob into structure of file  
Jul 15, 2004 6:10 AM (reply 4 of 4)



 
A File object represents a file on disk. If you just want to read the file into memory use a byte array. You can write the data to a java.io.ByteArrayOutputStream then use its methods for retrieving the data.

Ted.
 
This topic has 4 replies on 1 page.