ObjectOutputStream oos = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream("test.dat")));
oos.writeObject("hello++++12345");
oos.writeObject("is verygood");
oos.close();
ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(new FileInputStream("test.dat")));
String s1 = (String) ois.readObject();
String s2 = (String) ois.readObject();
System.out.println(s1);
System.out.println(s2);
ois.close();
通过ObjectOutputStream序列化和使用ObjectInputStream反序列化
最新推荐文章于 2024-04-16 17:38:43 发布