Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Java (http://www.programmingforums.org/forum17.html)
-   -   decoding compressed BLOBS (http://www.programmingforums.org/showthread.php?t=15485)

ggilmour Mar 26th, 2008 12:58 AM

decoding compressed BLOBS
 
I'm working on a program that accesses an Interbase 5.x database using firebird/jaybird and the jdbc libraries. I've run into a problem with some compressed BLOB fields though.

I'm able to stream the BLOB into a text file, but have had no luck with decompressing the data.

Every attempt I've made to send the BLOB's InputStream through a FilteredStream (such as InflatorInputStream or ZipInputStream) has failed.

Does anyone have any experience with compressing/decompressing BLOB fields with java? Where am I going wrong?

Thanks,

:


//Get the blob (in Test_Data column) and store it in the Java BLOB object.
//Get an inputStream from the BLOB object so we can read it.
Blob importantData = testResults.getBlob("Test_Data");
InputStream blobStream = importantData.getBinaryStream();
       
//Create our output file
File myFile = new File("BlobOut.txt");
FileOutputStream fout = new FileOutputStream(myFile,true);
       
// Create a ZipInputStream from the InputStream
ZipInputStream unZipBlob = new ZipInputStream(blobStream);
       
//Read from the BLOB's inputStream until it's empty.
       
while(unZipBlob.available() > 0)
//while(blobStream.available() > 0)
       
{
//write decompressed data to the output file
fout.write(unZipBlob.read());
               
//Write the raw compressed binary data. Appears to work  fine, but isn't readable!
//fout.write(blobStream.read());
}
       
               
//Close the file output stream.
fout.close();
}


ggilmour Mar 26th, 2008 12:23 PM

Re: decoding compressed BLOBS
 
Update: The BLOBs were compressed using the PKZIP 2.0 Deflate algorithm (Abbrevia's DeflateStream)

I'm having no luck setting up an InflaterInputStream though. It returns a zero or a 1 then dies.


All times are GMT -5. The time now is 2:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC