Hello,
I have read the Github manual page about compression but I can't figure how to make use of it properly.
Here's an example snippet from my app that works perfectly fine:
// serialize and write object to disk:
val writeFile = combinedColladaModel.serializedFile
val output = Output(FileOutputStream(writeFile))
modelSerializer.writeObject(output, sm)
output.close()
...
// later read the serialized file back as object:
val input = Input(FileInputStream(fileName!!))
val modelData: SerializedModel = k.readObject(input, SerializedModel::class.java)
input.close()
Now if I change the code to be like this:
// serialize and write object to disk: (OK):
val writeFile = combinedColladaModel.serializedFile
val output = Output(DeflaterOutputStream(FileOutputStream(writeFile)))
modelSerializer.writeObject(output, sm)
output.close()
...
// later read the serialized file back as object (CRASH):
val input = Input(DeflaterInputStream(FileInputStream(fileName!!)))
val modelData: SerializedModel = k.readObject(input, SerializedModel::class.java)
input.close()
The object gets compressed and serialized to disk (the file on the disk now has significantly smaller size) but when I try to read it back to my application from the disk, as shown in the code above, I get "KryoException: Buffer underflow".
Is this the correct way to use the compression? Are there any code examples online showing how object compression, serialization and deserialization can be done with Kryo?
Thanks!