4 public class Serialization
6 public static void main(String
[] args
)
7 throws IOException
, ClassNotFoundException
9 File f
= new File("test.ser");
10 ObjectOutputStream objStream
=
11 new ObjectOutputStream(new FileOutputStream(f
));
12 objStream
.writeInt(8);
13 objStream
.writeObject(new Integer(99));
14 List l
= new LinkedList();
15 l
.add(new Integer(1));
16 l
.add(new Short((short) 7));
17 l
.add(new Float(9.95));
18 l
.add(new Long(-900000000000001l));
19 l
.add(new Double(-3.14159));
20 l
.add(new Character('X'));
21 l
.add(new Byte((byte) 'z'));
22 objStream
.writeObject(l
);
25 ObjectInputStream ois
= new ObjectInputStream(new FileInputStream(f
));
26 System
.out
.println (ois
.readInt());
27 System
.out
.println (ois
.readObject());
28 System
.out
.println (ois
.readObject());