package Date26;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
public class ObjectStreamDemo {
public static void main(String[] args)throws IOException {
writeObj();
}
public static void writeObj() throws IOException {
ObjectOutputStream oos =
new ObjectOutputStream(new FileOutputStream("obj.txt"));
oos.writeObject(new Person("lisi",30));
oos.close();
}
} |