Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class World {
- public World() { }
- public class Person implements Serializable {
- private static final long serialVersionUID = 1L;
- private String name;
- public Person() { }
- public String toString() {
- return "{" + name + "}";
- }
- }
- private Person person = new Person();
- synchronized public void save() {
- try {
- FileOutputStream fos = new FileOutputStream("save.ser");
- BufferedOutputStream bos = new BufferedOutputStream(fos);
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(person);
- oos.close();
- } catch (Exception e) {
- // TODO: handle exception
- e.printStackTrace();
- }
- }
- }
Add Comment
Please, Sign In to add comment