Last active
September 11, 2017 11:27
-
-
Save walf443/fee95ac45f7d5b38d380609430dd177b to your computer and use it in GitHub Desktop.
interfaceをSerializableにして問題ないか検証してみた
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
import java.io.* | |
interface OnClickListener: Serializable { | |
fun onClick() | |
} | |
fun main(args: Array<String>) { | |
val l: OnClickListener = object: OnClickListener { | |
override fun onClick() { | |
println("\nhello kt") | |
} | |
} | |
val fos = FileOutputStream("tmp.txt") | |
val oos = ObjectOutputStream(fos) | |
oos.writeObject(l) | |
oos.close() | |
fos.close() | |
val oos2 = ObjectOutputStream(System.out) | |
oos2.writeObject(l) | |
val fis = FileInputStream("tmp.txt") | |
val ois = ObjectInputStream(fis) | |
val listener: OnClickListener = ois.readObject() as OnClickListener | |
listener.onClick() | |
ois.close() | |
fis.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
出力