Using of

Using of

Post by Davi » Thu, 05 Mar 2009 02:35:03


I try to compress an array of bytes using The important thing is that it should not written into a file, but the output should be an array of bytes too.

I try that :

toConvert = 'Hello';
in = unicode2native(toConvert);

out =;
gzipOutStream =;
output = out.toByteArray();


but it seems that the method .write for the object gzipOutStrem don't work.

in gzip.m of matlab they use :
streamCopier = ...;

in order to write into the GZIPOutputStream, but it seems to work only with files.

My goal is to have something like a box which compress into gzip/deflate format an array of bytes, and outputs the compressed array of bytes.

Thanks for your help

Using of

Post by Ed Y » Sun, 22 Mar 2009 04:15:20

Have you looked at[Input|Output]Stream?


Using of

Post by Davi » Sun, 22 Mar 2009 05:09:02

Not yet, thanks for the idea !


Using of

Post by Jesse Hopk » Fri, 23 Oct 2009 23:07:19

David -

I'm curious if you got this to work. There were a couple files on the file exchange here that seem to do what you are trying:

I tried running these, and the compression script worked fine (dzip.m), however the deflate script (dunzip.m) was throwing java exceptions (see me comments in the file exchange). I was running these in R2008b. Have you tried these files?