Implementing in-memory compression for objects in Java

后端 未结 8 1961
忘了有多久
忘了有多久 2020-12-13 02:29

We have this use case where we would like to compress and store objects (in-memory) and decompress them as and when required.

The data we want to compress is quite

8条回答
  •  孤城傲影
    2020-12-13 02:35

    One proposal could be to use a combination of the following streams:

    • ObjectOutputStream / ObjectInputStream for serializing/deserializing Java objects
    • GZIPOutputStream / GZIPInputStream for compressing/uncompressing. There are other options to be found in the java.util.zip package.
    • ByteArrayOutputStream / ByteArrayInputStream for storing the data in memory as a byte array

提交回复
热议问题