| Author |
Doing something dumb trying to stream nested streams
|
Pat Farrell
Rancher
Joined: Aug 11, 2007
Posts: 4442
|
|
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
Joined: Mar 05, 2008
Posts: 2818
|
|
|
I think GZIP may not actually do anything until you close() it. Calling flush() may not be enough.
|
 |
Pat Farrell
Rancher
Joined: Aug 11, 2007
Posts: 4442
|
|
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
Joined: Mar 05, 2008
Posts: 2818
|
|
|
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
Joined: Oct 27, 2005
Posts: 19232
|
|
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.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Doing something dumb trying to stream nested streams
|
|
|