Here is an example code
ByteArrayOutputStream baos = new ByteArrayOutputStream(bufSize);
GZIPOutputStream gzos = new GZIPOutputStream1(baos);
gzos.write(...)
...
gzos.write(...)
...
// Would the content get flushed properly?
gzos.flush()
byte[] bytes = baos.toByteArray();
// Use bytes wherever you want
...
// Would this reset things for gzos?
baos.reset()
gzos.write(...)
...
gzos.write(...)
...
bytes = baos.toByteArray();
...
So, once the compressed byte array is used somewhere, I want to reset the stream. I have two concerns. I read somewhere that GZIPOutputStream
's flush method do not necessarily always flushes the content? Is that true still for Java 7? If that works, is calling reset of the ByteArrayOutputStream
object enough to reset things for the GZIPOutputStream
object?