commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Larson, David" <david.lar...@csfb.com>
Subject FW: bzip compression
Date Tue, 17 Feb 2004 17:50:02 GMT
Henri directed me to this email group.  Can anyone provide some insight on
bzip compression usage for purposes other than writing to a file?  thx...

> Hi Henri,
>
> I'm was planning on evaluating the use of bzip compression (instead of the
> default java compression algorithms) for purposes of storage in a database.
> So I grabbed your bzip libraries for this purpose.
>
> The exmpales on the Jakarta website are limited to a usage pattern for
> reading/writing to/from a file.  Is it appropriate to use this API for
storage
> to/from a byte array (for storage in a DB)?
>
> Got the source from...
>
> http://jakarta.apache.org/commons/sandbox/compress/
>
> Here's what I'm trying...
>
> public static ZipObject bZip(Serializable inObj) throws IOException {
>
>     ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
>     ObjectOutputStream objOut = new ObjectOutputStream(byteOut);
>     objOut.writeObject(inObj);
>
>     byte[] dataArray = byteOut.toByteArray();
>     int origSize = dataArray.length;
>
>     ByteArrayOutputStream bZipByteOut = new ByteArrayOutputStream();
>     CBZip2OutputStream bZipOut = new CBZip2OutputStream(bZipByteOut);
>
>     bZipOut.write(dataArray, 0, dataArray.length);
>     byte[] compressedDataArray = bZipByteOut.toByteArray();
>
> ...but the output is eratic and can never be decmopressed (but am able to
save
> to a database).
>
> Am I doing something foolishly wrong?

==============================================================================
This message is for the sole use of the intended recipient. If you received
this message in error please delete it and notify us. If this message was
misdirected, CSFB does not waive any confidentiality or privilege. CSFB
retains and monitors electronic communications sent through its network.
Instructions transmitted over this system are not binding on CSFB until they
are confirmed by us. Message transmission is not guaranteed to be secure.
==============================================================================


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message