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


Groups > comp.lang.java.help > #1395

Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha.

From markspace <-@.>
Newsgroups comp.lang.java.help
Subject Re: ByteArrayOutputStream gotcha, actually GZIPOutputStream gotcha.
Date 2011-11-27 16:41 -0800
Organization A noiseless patient Spider
Message-ID <jaulbt$pq9$1@dont-email.me> (permalink)
References <2gd5d7l48ouslkp3a2umj57917prptpcel@4ax.com> <deg5d71fo69lfb0e8m3oelusj3s3i81h9p@4ax.com>

Show all headers | View raw


On 11/27/2011 3:07 PM, Roedy Green 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.


Because Zip files need to write some final data, which can only be 
written after the rest of the stream is completed.

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

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