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._
4
4
5
5
object JavaByteSerialization {
6
6
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
+ }
14
9
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
+ }
20
17
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 ]
22
22
}
23
23
}
You can’t perform that action at this time.
0 commit comments