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();

你可能感兴趣的:(object)