Skip to content

Instantly share code, notes, and snippets.

@dvdciri
Last active July 30, 2019 11:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dvdciri/fb6861ac66009f4d355c754a33ba8da1 to your computer and use it in GitHub Desktop.
Save dvdciri/fb6861ac66009f4d355c754a33ba8da1 to your computer and use it in GitHub Desktop.
Koltin object serialisation
object AnObject : Serializable
val byteArrayOutputStream = ByteArrayOutputStream()
val objectOutputStream = ObjectOutputStream(byteArrayOutputStream)
objectOutputStream.writeObject(AnObject)
val byteArray = byteArrayOutputStream.toByteArray()
val byteArrayInputStream = ByteArrayInputStream(byteArray)
val objectInputStream = ObjectInputStream(byteArrayInputStream)
val outputObject = objectInputStream.readObject() as AnObject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment