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