Is it possible to search for a file with comrpessed objects in java?

I read the following bit from ORACLE :

Can I execute methods in compressed versions of my objects like isempty (zip (serial (x)))?

This is not realistic for any objects due to the encoding of objects. For a specific object (e.g. String) you can compare the received bitstreams. The encoding is stable, because each time the same object is encoded, it is encoded into the same set of bits.

So, I got this idea, say, if I have a char array from 4M something long, is it possible for me to compress it to several hundred bytes with GZIPOutputStream, and then display the entire file in memory, and do an arbitrary search on it by comparing bit? Say, if I'm looking for a char sequence "abcd", can I somehow get the bit sequence of the compressed version "abcd", and then just search for it? Thank.

+3
source share
1 answer

You cannot use gzip or the like to do this as encoding each byte change when processing a stream. that is, the only way to determine what a byte means is to read all previous bytes.

, String . .

+1

All Articles