序列化
@Test public void test12() throws IOException { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("object.dat")); oos.writeObject(new String("白发渔樵江渚上")); oos.close(); }
反序列化
@Test public void test13() throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream(new FileInputStream("object.dat")); Object o = ois.readObject(); System.out.println(o); ois.close(); }