//:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** @author John Miller * @version 1.6 * @date Mon May 25 16:28:22 EDT 2020 * @see LICENSE (MIT style license file). */ package scalation.util import java.io._ //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** The `AnObject` object is a sample singleton object that is made serialiable via * "extends Serializable". May also make is serializable by making it a case object. */ object AnObject extends Serializable { val x = 2.0 val s = "Here's a string" } // AnObject object //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: /** The `ObjectSerialization` object is used to serialize a Scala singleton object. * > runMain scalation.util.ObjectSerialization */ object ObjectSerialization extends App { println (AnObject) val oos = new ObjectOutputStream (new FileOutputStream ("/tmp/AnObject.ser")) oos.writeObject (AnObject) oos.close () } // ObjectSerialization object