Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #1397
| From | "John B. Matthews" <nospam@nospam.invalid> |
|---|---|
| Newsgroups | comp.lang.java.help |
| Subject | Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha. |
| Date | 2011-11-27 20:13 -0500 |
| Organization | The Wasteland |
| Message-ID | <nospam-3178DA.20133827112011@news.aioe.org> (permalink) |
| References | <2gd5d7l48ouslkp3a2umj57917prptpcel@4ax.com> <deg5d71fo69lfb0e8m3oelusj3s3i81h9p@4ax.com> |
In article <deg5d71fo69lfb0e8m3oelusj3s3i81h9p@4ax.com>, Roedy Green <see_website@mindprod.com.invalid> wrote: > On Sun, 27 Nov 2011 14:41:08 -0800, Roedy Green > <see_website@mindprod.com.invalid> wrote, quoted or indirectly quoted > someone who said : > > >Here a SSCCE to point out a gotcha in ByteArrayOutputStream, > >admittedly not the most commonly used class. It is actually a bug. > >What I have discovered conflicts with the documentation > > I did some more experiments and discovered the problem is not > actually with ByteArrayOutputStream but with GZIPOutputStream. > flush() does not cut it for GZIPOutputStream. It wants finish(). > When you do that you can get the correct result after the flush but > before close. > > I wonder why they did not call it flush. You can call flush multiple > times, but perhaps you can call finish only once. Interestingly, the GZIP file format, RFC 1952, specifies a trailer that includes a CRC value and size, which are written by finish(). It looks like you can call finish() repeatedly "when applying multiple filters in succession to the same output stream." Presumably GZIPInputStream can handle the reverse, but I haven't seen an example. <http://www.gzip.org/zlib/rfc-gzip.html> -- John B. Matthews trashgod at gmail dot com <http://sites.google.com/site/drjohnbmatthews>
Back to comp.lang.java.help | Previous | Next — Previous in thread | Find similar
ByteArrayOutputStream gotcha Roedy Green <see_website@mindprod.com.invalid> - 2011-11-27 14:41 -0800
Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha. Roedy Green <see_website@mindprod.com.invalid> - 2011-11-27 15:07 -0800
Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha. markspace <-@.> - 2011-11-27 16:41 -0800
Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha. Roedy Green <see_website@mindprod.com.invalid> - 2011-11-27 16:58 -0800
Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha. "John B. Matthews" <nospam@nospam.invalid> - 2011-11-27 20:13 -0500
csiph-web