When using the deflate-method of java.util.zip.Deflater, a byte[] has to be supplied as the argument, how big should that byte[] be initialized to? I’ve read there’s no guarantee the compressed data will even be smaller that the uncompressed data. Is there a certain % of the input I should go with?
Currently I make it twice as big as the input
When using the deflate-method of java.util.zip.Deflater, a byte[] has to be supplied as the
Share
After calling
deflate, callfinishedto see if it still has more to output. eg:If you just want to collect all of the bytes in-memory you can use a ByteArrayOutputStream. eg: