import java.io.*;
import java.util.*;
public class Persistencia implements Serializable  {

  int i;
  long l;
  double d;
  String s;
  Hashtable h;
  public static void main(String [] args) {
       Persistencia p = new Persistencia();
       p.i = 9;
       p.l = 100800;
       p.d = Math.PI;
       p.s = "hola mundo persistente";
       p.h = new Hashtable();
       for (char ch='a';ch<'z';ch++) {
            p.h.put(""+ch,new Integer((int) ch));
       }
       try {
       ObjectOutputStream out = 
       new ObjectOutputStream(
             new BufferedOutputStream(
               new FileOutputStream("p.ser")));
       out.writeObject(p);
       out.close();
       BufferedInputStream buffIn=
          new BufferedInputStream( 
            new FileInputStream("p.ser"),1);
       ObjectInputStream in = new ObjectInputStream(buffIn);
       Object o=in.readObject();
       if (o instanceof Persistencia) {
         Persistencia p2 = (Persistencia) o;
         System.out.println(p2.i+" "+p2.l+" "+p2.d+" "+p2.s);
         Enumeration llaves = p2.h.keys();
         while ( llaves.hasMoreElements() ) {
              String llave = (String)llaves.nextElement();
               Integer intg=(Integer)p2.h.get(llave);
               System.out.println(llave+" "+intg);
         }       
       }
       in.close();
       } catch (Exception ex) {
            ex.printStackTrace();
       } 
  }

}