> Hmm. That seems strange. The number of bytes returned by each read()
> means nothing much in itself, of course, or do you mean that the /total/
> number of bytes read is the same as the compressed size ?
I meant the total size. However, there was a bug in my code. I was reading
into a buffer equal in size to that of the compressed data, so naturally I
was receiving only that many bytes.
[my keyboard died right in the middle of typing this. I had to go out to
the store for a new one]
You are correct that ZipEntry has the decompressed data via its InputStream.
I wrote the ASCII value of each to stdout one byte at a time, and each byte
is correct. I am also getting the correct number of bytes.
My problem is that my FileWriter is writing a lot of extra bytes to the file
for some reason. It is also somehow altering the bytes that it writes,
which is why I initially thought the Zip objects weren't correct. It seems
at first glance to be masking out bit 5 of every byte for some reason.
My test JPEG is 2986 bytes uncompressed, but the FileWriter is outputting
5598 bytes. This is my decompression loop code:
while ( (nBytesRead = input.read(baUncompressed)) > -1)
{
nTotal += nBytesRead;
System.out.println("Bytes read: " + nBytesRead);
for (int i = 0;i < nBytesRead;i++)
{
System.out.println(i + "=[" + baUncompressed[i] + "]");
writerUncompressed.write(baUncompressed[i]);
}
}
writerUncompressed.close();
Roedy Green - 14 Nov 2005 01:47 GMT
On Sun, 13 Nov 2005 21:51:12 GMT, Tony O'Bryan
<storm_reaver@yahoo.com> wrote, quoted or indirectly quoted someone
who said :
>[my keyboard died right in the middle of typing this.
You can often revive them by popping keys and cleaning out with a
Q-tip soaked in alcohol. Bits of grit or hair in the keyboard can
block a key from contacting properly.
Sometimes all you have to do in hit the alt,ctrl and shift keys to get
the software back in sync. And don't forget to check keypad mode is
off.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Roedy Green - 14 Nov 2005 01:49 GMT
On Sun, 13 Nov 2005 21:51:12 GMT, Tony O'Bryan
<storm_reaver@yahoo.com> wrote, quoted or indirectly quoted someone
who said :
>My problem is that my FileWriter is writing a lot of extra bytes to the file
>for some reason.
that is because the bytes are perfect as they are. Just write them out
as raw bytes. See http://mindprod.com/applets/fileio.html
for how.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
Tony O'Bryan - 14 Nov 2005 02:30 GMT
> that is because the bytes are perfect as they are. Just write them out
> as raw bytes. See http://mindprod.com/applets/fileio.html
> for how.
Writing them raw was what I was trying to do. Being away from Java for
almost two years has taken its toll on my memory of the class libraries.
Actually, writing them to disk was just supposed to be a technique to verify
the accuracy of the Zip read. My application doesn't actually need to
write anything it unzips. I just don't like it when something doesn't
work, even a throwaway code path, so I had to figure it out -grin-.