Hello,
I need to compress a ByteArrayOuputStream (PDF) without saving it on
the disk, so I need to zip a stream which won't be convert as a file.
Do you know if it is possible ?
thx !
I was under the impression that a PDF is already compressed with a
similar algorithm to ZIP compression. You get very little benefit
from compressing a compressed file (often times you can only make it
bigger)
Anyway, Many people have given you the tools you need. ZipEntry indeed
specifies a "file name". But that is the "file name" in the .zip file
itself. You add the name, and then add the data associated with that
name.
Just to clarify, a .zip file contains a set of compressed "files"...
You can compress arbitrary data in a .zip file, but you need to
specify a name for it to work.
Alternatively, as Nigel Wade suggested, you can use the GZIP input and
output streams. GZIP compression does *not* care about "files". It
is probably more appropriate for what you are doing... It is also
supported in http. The most popular browsers can automatically
uncompress a gzipped response.