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

Can someone point to "todays" solution please?

Marshall appears to have been deprecated and removed and pickling isn't yet included(?) in spite of being mentioned up to 2 years ago... (might be import locations are not jiving but can't tell yet till I find out what IS supposed to work as of 2015/05/11)

I'm commenting here as this gist comes up in a lot of searches while trying to find a workable answer.

@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