Skip to content

Instantly share code, notes, and snippets.

@thomasnield
Last active September 18, 2016 14:53
Show Gist options
  • Save thomasnield/ca3ea5abe010e8a42cbabc5898655b46 to your computer and use it in GitHub Desktop.
Save thomasnield/ca3ea5abe010e8a42cbabc5898655b46 to your computer and use it in GitHub Desktop.
//compile 'de.javakaffee:kryo-serializers:0.38'
class KryoImmutableListTest {
class MyItem(val x: Int, val y: Int) {
private constructor(): this(-1,-1)
override fun toString() = "$x-$y"
}
@Test
fun test() {
val kryo = Kryo()
kryo.register(ImmutableList::class.java, ImmutableListSerializer())
val output = Output(FileOutputStream("file.bin"))
val items = ImmutableList.of(MyItem(5,10),MyItem(1,9))
println(items)
kryo.writeObject(output, items)
output.close()
val input = Input(FileInputStream("file.bin"))
val u = kryo.readObject(input, ImmutableList::class.java)
input.close()
println("u = ${u}")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment