
613I/O Techniques
ze.setSize(numel(data));
zos.setLevel(9);
zos.putNextEntry(ze);
dataInBytes = int8(data); % or: getByteStreamFromArray(data)
zos.write(dataInBytes,0,numel(dataInBytes));
zos.finish;
zos.close;
compressedDataArray = baos.toByteArray; % array of MATLAB int8
% Gzip variant:
baos = java.io.ByteArrayOutputStream;
zos = java.util.zip.GZIPOutputStream(baos);
dataInBytes = int8(data); % or: getByteStreamFromArray(data)
zos.write(dataInBytes,0,numel(dataInBytes));
zos.finish;
zos.close;
compressedDataArray = baos.toByteArray; % array of MATLAB int8
Similar logic applies to reading compressed data: We could indeed use unzip/