序列化 保存到一个文件

版权声明:随便转载了.............. https://blog.csdn.net/lijingshan34/article/details/78071887

  a)Make a FileOutputStream

  java 代码
  FileOutputStream fs = new FileOutputStream(“foo.ser”);

  b)Make a ObjectOutputStream

  java 代码
  ObjectOutputStream os = new ObjectOutputStream(fs);

  c)write the object

  java 代码
  os.writeObject(myObject1);
  os.writeObject(myObject2);
  os.writeObject(myObject3);

  d) close the ObjectOutputStream

  java 代码
  os.close();

猜你喜欢

转载自blog.csdn.net/lijingshan34/article/details/78071887