java 对象序列化与反序列化 FileInputSteam.readObject,writeObject

       T t=new T();
        t.k=8;
        FileOutputStream fos=new FileOutputStream("d:/a.dat");
        ObjectOutputStream oos=new ObjectOutputStream(fos);
        oos.writeObject(t);
        oos.flush();
        oos.close();
        
        FileInputStream fis=new FileInputStream("d:/a.dat");
        ObjectInputStream ois=new ObjectInputStream(fis);
        T tReaded=(T)ois.readObject();
        System.out.println(tReaded.d+" "+tReaded.i+" "+tReaded.j+" "+tReaded.k);
        ois.close();

posted on 2012-06-25 21:40  雨渐渐  阅读(228)  评论(0编辑  收藏  举报

导航