Last active
July 30, 2019 11:46
-
-
Save dvdciri/fb6861ac66009f4d355c754a33ba8da1 to your computer and use it in GitHub Desktop.
Koltin object serialisation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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