summaryrefslogtreecommitdiff
path: root/test/files/run/si5374.scala
blob: a5678c3a813fa3a18a00902ecf378cb60ee9ea2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import collection.mutable.ListBuffer
import java.io._



object Test {
  
  def main(args: Array[String]) {
    ticketExample()
    emptyListBuffer()
  }
  
  def ticketExample() {
    val baos = new ByteArrayOutputStream
    val oos = new ObjectOutputStream(baos)
    oos.writeObject( ListBuffer(1,2,3) )
    val bais = new ByteArrayInputStream( baos.toByteArray )
    val ois = new ObjectInputStream(bais)
    val lb = ois.readObject.asInstanceOf[ListBuffer[Int]]
    val lb2 = ListBuffer[Int]() ++= lb
    
    lb2 ++= List(1)
    lb ++= List(1)
    println(lb)
    println(lb2)
  }
  
  def emptyListBuffer() {
    val baos = new ByteArrayOutputStream
    val oos = new ObjectOutputStream(baos)
    oos.writeObject( ListBuffer() )
    val bais = new ByteArrayInputStream( baos.toByteArray )
    val ois = new ObjectInputStream(bais)
    val lb = ois.readObject.asInstanceOf[ListBuffer[Int]]
    
    println(lb)
  }
  
}