// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.*;
import java.beans.*;
import java.io.*;

public class SerTest implements Serializable {
    public int a;
    private int b;
    private transient int c;
    private HashMap hm1;
    private HashMap hm2;
    public SerTest() {
        a = 0;
        b = 0;
        c = 0;
        hm1 = new HashMap();
        hm2 = new HashMap();
    }
    public SerTest(int a, int b, int c, String v) {
        this.a = a;
        this.b = b;
        this.c = c;
        hm1 = new HashMap();
        hm2 = new HashMap();
        hm1.put("k1", v);
        hm2.put("k2", v);
    }
    public int getB() {
        return b;
    }
    public int getC() {
        return c;
    }
    public HashMap getHm1() {
        return hm1;
    }
    public void setB(int b) {
        this.b = b;
    }
    public void setC(int c) {
        this.c = c;
    }
    public void setHm1(HashMap hm1) {
        this.hm1 = hm1;
    }
    public String toString() {
        return (a + " " + b + " " + c + " " + hm1 + " " + hm2);
    }
    public static void main(String[] args) throws Exception {
        SerTest st1 = new SerTest(1, 2, 3, "V");
        XMLEncoder xe = new XMLEncoder(new FileOutputStream("C:\\xml.dat"));
        xe.writeObject(st1);
        xe.close();
        XMLDecoder xd = new XMLDecoder(new FileInputStream("C:\\xml.dat"));
        SerTest st2 = (SerTest)xd.readObject();
        System.out.println(st1 + " -> " + st2);
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("C:\\bin.dat"));
        oos.writeObject(st1);
        oos.close();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("C:\\bin.dat"));
        SerTest st3 = (SerTest)ois.readObject();
        System.out.println(st1 + " -> " + st3);
    }
}
