I have a big String content, compressed as GZIP and stored as BLOB in database. While extracting from DB, I am able to retrieve the string out of it as:
try (
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
BufferedInputStream bufis = new BufferedInputStream(new GZIPInputStream(bis));
ByteArrayOutputStream bos = new ByteArrayOutputStream()
) {
byte[] buf = new byte[4096];
int len;
while ((len = bufis.read(buf)) > 0) {
bos.write(buf, 0, len);
}
retval = bos.toString();
}
My problem here is for some input records, I have this BLOB too big, and I have to grep hardly 5-6 lines from BLOB. And I have to process these records in bulk which is shooting up memory footprints.
Is there a way to extract content from GZIP in chunks, and I can discard all leftover chunks if I get those lines in initial parts only.
Thanks for the help in advance.