Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30164

Re: Exception in thread "main" java.util.zip.ZipException: Not in GZIP format

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Steven Simpson <ss@domain.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Exception in thread "main" java.util.zip.ZipException: Not in GZIP format
Date Thu, 23 Oct 2014 14:31:24 +0100
Organization A noiseless patient Spider
Lines 26
Message-ID <cicnhb-cl8.ln1@s.simpson148.btinternet.com> (permalink)
References <38eee3eb-4817-4a14-b823-4609b421b3fa@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Info mx02.eternal-september.org; posting-host="8273798d0ed7378aea0c13584858baac"; logging-data="1897"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+5K1heGJLYCUe6fknydbW4TcBZXSFpt1o="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <38eee3eb-4817-4a14-b823-4609b421b3fa@googlegroups.com>
Cancel-Lock sha1:Ul8Hv9NcijZUsJ6nH+NGXUKHQJA=
Xref csiph.com comp.lang.java.programmer:30164

Show key headers only | View raw


On 23/10/14 09:51, takouarnauld@gmail.com wrote:
> I'm trying in my program to Compress/Decompress data using GZIP streams and when using the charset "ISO-8859-1", everything working well but when changing the charset to "UTF-8", i'm getting the Error message "Exception in thread "main" java.util.zip.ZipException: Not in GZIP format".
> this is my code:

> 	        ByteArrayOutputStream out = new ByteArrayOutputStream();
...
> 	        String outStr = out.toString("UTF-8");

I printed out the bytes from out.toByteArray() and outStr.getBytes("UTF-8"):

Bytes from gzip:
0000: 1F 8B 08 00 00 00 00 00 00 00 CB AD 54 48 49 2C
0010: 49 04 00 29 AD 56 16 07 00 00 00
Bytes as string:
0000: 1F EF BF BD 08 00 00 00 00 00 00 00 CB AD 54 48
0010: 49 2C 49 04 00 29 EF BF BD 56 16 07 00 00 00

The interpretation of the bytes from gzip as UTF-8 fails because 8B 08 
isn't a valid UTF-8 sequence.  The conversion seems to deal with this by 
replacing 8B with EF BF BD, which is the UTF-8 encoding for U+FFFD 
(REPLACEMENT CHARACTER).  It does the same with AD later.


-- 
ss at comp dot lancs dot ac dot uk

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Exception in thread "main" java.util.zip.ZipException: Not in GZIP format takouarnauld@gmail.com - 2014-10-23 01:51 -0700
  Re: Exception in thread "main" java.util.zip.ZipException: Not in GZIP format Martin Gregorie <martin@address-in-sig.invalid> - 2014-10-23 11:19 +0000
  Re: Exception in thread "main" java.util.zip.ZipException: Not in GZIP format Steven Simpson <ss@domain.invalid> - 2014-10-23 14:31 +0100
  Re: Exception in thread "main" java.util.zip.ZipException: Not in GZIP format Mike Amling <mamling@chaff.us> - 2014-10-23 09:30 -0500

csiph-web