Skip to content

Instantly share code, notes, and snippets.

@vetler
Created December 15, 2011 08:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vetler/1480346 to your computer and use it in GitHub Desktop.
Save vetler/1480346 to your computer and use it in GitHub Desktop.
import scala.util.Marshal
import scala.io.Source
import scala.collection.immutable
import java.io._
object Example {
class Foo(m: String) extends scala.Serializable {
val message = m
}
def main(args: Array[String]) {
val foo = new Foo("qweqwe")
val out = new FileOutputStream("out")
out.write(Marshal.dump(foo))
out.close
val in = new FileInputStream("out")
val bytes = Stream.continually(in.read).takeWhile(-1 !=).map(_.toByte).toArray
val bar: Foo = Marshal.load[Foo](bytes)
println(bar.message)
}
}
@techmag
Copy link

techmag commented May 11, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment