• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doing something dumb trying to stream nested streams  RSS feed

 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I"m close, but I am not getting the expected output



Specifically, if I try to use normal shell utilities to de-base64 and gunzip, I don't get the input string back.
I must be doing something trivially wrong.

Thanks
Pat
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think GZIP may not actually do anything until you close() it. Calling flush() may not be enough.
 
Pat Farrell
Rancher
Posts: 4686
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
close() seems to make it work. Thanks

I didn't want to call close() because I was worried that it would make the buffer be no longer available.
 
Mike Simmons
Ranch Hand
Posts: 3090
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the gzip algorithm wants to know that it has all the data before it compresses it. Or at least, before it considers the compression complete enough to send. A ZipOutputStream might work differently for you.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pat Farrell wrote:I didn't want to call close() because I was worried that it would make the buffer be no longer available.

Normally that's a good thought, but ByteArrayOutputStream doesn't clear its buffer at all.

But GZIPOutputStream also had method finish() that does the same without closing the underlying stream.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!