Created
December 15, 2011 08:20
-
-
Save vetler/1480346 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.