Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #30164
| 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 | 2014-10-23 14:31 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <cicnhb-cl8.ln1@s.simpson148.btinternet.com> (permalink) |
| References | <38eee3eb-4817-4a14-b823-4609b421b3fa@googlegroups.com> |
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
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