Java Serialization: Writing an Object Stream

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import java.io.*;
public class SerializeBoolean {
    public SerializeBoolean() {
        Boolean booleanDAta = new Boolean("true");
        try {
            FileOutputStream fos = new FileOutputStream("boolean.ser");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(booleanDAta);
            oos.close();
        } catch (IOException ie) {
            ie.printStackTrace();
        }
    }
    public static void main(String [] args) {
        SerializeBoolean ab = new SerializeBoolean();
    }
}

Leave a Reply