It is possible compress an stream (without saving in a file?)
I'm using java.util.zip package to compress/uncompress streams.
My objective is translate a file into a string (coding it to base64), and then, decoding it.
But, before to coding it i'm trying to compress the stream in order to have less bytes.
For compress the file, i think that i've no problem. The problem is with the uncompressing.
I give a pice of code to have more accurate idea :
String cad;
.... /* now, this 'cad' is the result of compressed OutputStream (GZIPOutputStream.toString()) */
....
ByteArrayInputStream bis = new ByteArrayInputStream(cad.getBytes());
GZIPInputStream gis = new GZIPInputStream(bis);
ByteArrayOutputStream bou = new ByteArrayOutputStream();
...
byte[] buffer = new byte[gis.available()];
gis.read(buffer); /* here it crash with this error #1 */
bou.write(buffer);
bou.flush();
...
But when JVM wants to read directly from GZIPInputStream #1 it crashes with this error :
java.util.zip.ZipException: oversubscribed literal/length tree
...
I'm using GZIPInputStream but i'm in a Windows plataform, i hope that this fact wasn't a problem.
The main reason to the utilitzation of GZIPInputStream is becouse it seems less dependent of file (if you use a ZipInputStream class you need an ZipEntry , etc...). I don't know if it is possible to do the compression of stream without file with ZipInputStream, but i think that no.
Thanks for all, and sorry about my english, it isn't my natural language, but i hope that more or less you understand my message.

