File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed
jvm/src/test/scala/scala/xml Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change @@ -4,20 +4,20 @@ import java.io._
44
55object JavaByteSerialization {
66 def roundTrip [T ](obj : T ): T = {
7- def serialize (in : T ): Array [Byte ] = {
8- val bos = new ByteArrayOutputStream ()
9- val oos = new ObjectOutputStream (bos)
10- oos.writeObject(in)
11- oos.flush()
12- bos.toByteArray()
13- }
7+ deserialize[T ](serialize[T ](obj))
8+ }
149
15- def deserialize (in : Array [Byte ]): T = {
16- val bis = new ByteArrayInputStream (in)
17- val ois = new ObjectInputStream (bis)
18- ois.readObject.asInstanceOf [T ]
19- }
10+ def serialize [T ](in : T ): Array [Byte ] = {
11+ val bos = new ByteArrayOutputStream ()
12+ val oos = new ObjectOutputStream (bos)
13+ oos.writeObject(in)
14+ oos.flush()
15+ bos.toByteArray()
16+ }
2017
21- deserialize(serialize(obj))
18+ def deserialize [T ](in : Array [Byte ]): T = {
19+ val bis = new ByteArrayInputStream (in)
20+ val ois = new ObjectInputStream (bis)
21+ ois.readObject.asInstanceOf [T ]
2222 }
2323}
You can’t perform that action at this time.
0 commit comments