The Kryo syntax is relatively similar to java serialization. A kryo object is created, as well as an output / input, and one of the kryos methods is used to serialize / deserialize
kryo.writeClassAndObject(output, object); //for if the concrete class isn't known (can be null)kryo.writeObjectOrNull(output, someObject); //if the object could be nullkryo.writeObject(output, someObject); //can't be null and concrete class is known
Each entry is associated with reading.
SomeClass object = (SomeClass)kryo.readClassAndObject(input);SomeClass someObject = kryo.readObjectOrNull(input, SomeClass.class);SomeClass someObject = kryo.readObject(input, SomeClass.class);
The following is an example of using writeClassAndObject, which serializes Vector3d to and from a file.
public class KryoTest { public static void main(String[] args){ Vector3d someObject=new Vector3d(1,2,3);
All updated documentation has now moved to github; https://github.com/EsotericSoftware/kryo#quickstart
source share