From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Load variable from java InputStream
Date: Thu, 15 Nov 2012 22:34:17 +0000 (UTC)
Organization: Authentix Inc
Lines: 13
Message-ID: <k83ql8$pi$>
References: <i5p4v1$5kp$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1353018857 818 (15 Nov 2012 22:34:17 GMT)
NNTP-Posting-Date: Thu, 15 Nov 2012 22:34:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 3067624
Xref: comp.soft-sys.matlab:782884

I was looking at the same problem and discovered a solution that uses  This is an output stream that gathers bytes and then you can request them as a byte array.  I use streamCopier just like it is used in extractArchive.m, to copy from the zip entry to the ByteArrayOutputStream.

entry = zipFile.getEntry('myentry.txt');
stream = zipFile.getInputStream(entry);
byteoutstream =;
streamCopier =;
streamCopier.copyStream(stream, byteoutstream);
sbytes = byteoutstream.toByteArray();
ubytes = uint8(int16(sbytes) + 256*int16(sbytes < 0));

Since toByteArray() returns (signed) int8 and I want uint8, I manually apply the wrap-around at the end.