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反序列化
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.